configuration

package
v0.0.0-...-f7471f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package configuration is in charge of the validation and extraction of all the configuration details from environment variables.

Index

Constants

View Source
const (
	// EnvPrefix will be used for environment variable name prefixing.
	EnvPrefix = "DEVCLUSTER"

	// DefaultHTTPAddress is the address and port string that your service will
	// be exported to by default.
	DefaultHTTPAddress = "0.0.0.0:8080"

	// DefaultHTTPIdleTimeout specifies the default timeout for HTTP idling.
	DefaultHTTPIdleTimeout = time.Second * 15

	// DefaultHTTPCompressResponses compresses HTTP responses for clients that
	// support it via the 'Accept-Encoding' header.
	DefaultHTTPCompressResponses = true

	// DefaultEnvironment is the default environment
	DefaultEnvironment   = "prod"
	UnitTestsEnvironment = "unit-tests"

	// DefaultLogLevel is the default log level used in your service.
	DefaultLogLevel = "info"

	// DefaultLogJSON is a switch to toggle on and off JSON log output.
	DefaultLogJSON = false

	// DefaultGracefulTimeout is the duration for which the server gracefully
	// wait for existing connections to finish - e.g. 15s or 1m.
	DefaultGracefulTimeout = time.Second * 15

	// DefaultHTTPWriteTimeout specifies the default timeout for HTTP writes.
	DefaultHTTPWriteTimeout = time.Second * 15

	// DefaultHTTPReadTimeout specifies the default timeout for HTTP reads.
	DefaultHTTPReadTimeout = time.Second * 15

	// DefaultAuthClientLibraryURL is the default auth library location.
	DefaultAuthClientLibraryURL = "https://sso.prod-preview.openshift.io/auth/js/keycloak.js"

	// DefaultAuthClientConfigRaw specifies the auth client config.
	DefaultAuthClientConfigRaw = `` /* 222-byte string literal not displayed */

	// DefaultAuthClientConfigContentType specifies the auth client config content type.
	DefaultAuthClientConfigContentType = "application/json; charset=utf-8"

	// DefaultAuthClientPublicKeysURL is the default log level used in your service.
	DefaultAuthClientPublicKeysURL = "https://sso.prod-preview.openshift.io/auth/realms/devcluster-public/protocol/openid-connect/certs"

	// DefaultNamespace is the default k8s namespace to use.
	DefaultNamespace = "devcluster"
)

Variables

View Source
var (
	// Commit current build commit set by build script.
	Commit = "0"
	// BuildTime set by build script in ISO 8601 (UTC) format:
	// YYYY-MM-DDThh:mm:ssTZD (see https://www.w3.org/TR/NOTE-datetime for
	// details).
	BuildTime = "0"
	// StartTime in ISO 8601 (UTC) format.
	StartTime = time.Now().UTC().Format("2006-01-02T15:04:05Z")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config encapsulates the Viper configuration which stores the configuration data in-memory.

func New

func New() *Config

New creates a new configuration

func (*Config) GetAuthClientConfigAuthContentType

func (c *Config) GetAuthClientConfigAuthContentType() string

GetAuthClientConfigAuthContentType returns the auth config config content type (as set via config file or environment variable).

func (*Config) GetAuthClientConfigAuthRaw

func (c *Config) GetAuthClientConfigAuthRaw() string

GetAuthClientConfigAuthRaw returns the auth config config (as set via config file or environment variable).

func (*Config) GetAuthClientLibraryURL

func (c *Config) GetAuthClientLibraryURL() string

GetAuthClientLibraryURL returns the auth library location (as set via config file or environment variable).

func (*Config) GetAuthClientPublicKeysURL

func (c *Config) GetAuthClientPublicKeysURL() string

GetAuthClientPublicKeysURL returns the public keys URL (as set via config file or environment variable).

func (*Config) GetEnvironment

func (c *Config) GetEnvironment() string

GetEnvironment returns the environment such as prod, stage, unit-tests, e2e-tests, dev, etc

func (*Config) GetGracefulTimeout

func (c *Config) GetGracefulTimeout() time.Duration

GetGracefulTimeout returns the duration for which the server gracefully wait for existing connections to finish - e.g. 15s or 1m.

func (*Config) GetHTTPAddress

func (c *Config) GetHTTPAddress() string

GetHTTPAddress returns the HTTP address (as set via default, config file, or environment variable) that the app-server binds to (e.g. "0.0.0.0:8080").

func (*Config) GetHTTPCompressResponses

func (c *Config) GetHTTPCompressResponses() bool

GetHTTPCompressResponses returns true if HTTP responses should be compressed for clients that support it via the 'Accept-Encoding' header.

func (*Config) GetHTTPIdleTimeout

func (c *Config) GetHTTPIdleTimeout() time.Duration

GetHTTPIdleTimeout returns the duration for the idle timeout.

func (*Config) GetHTTPReadTimeout

func (c *Config) GetHTTPReadTimeout() time.Duration

GetHTTPReadTimeout returns the duration for the read timeout.

func (*Config) GetHTTPWriteTimeout

func (c *Config) GetHTTPWriteTimeout() time.Duration

GetHTTPWriteTimeout returns the duration for the write timeout.

func (*Config) GetLogLevel

func (c *Config) GetLogLevel() string

GetLogLevel returns the logging level (as set via config file or environment variable).

func (*Config) GetNamespace

func (c *Config) GetNamespace() string

GetNamespace returns the namespace in which the registration service and host operator is running

func (*Config) GetViperInstance

func (c *Config) GetViperInstance() *viper.Viper

GetViperInstance returns the underlying Viper instance.

func (*Config) IsLogJSON

func (c *Config) IsLogJSON() bool

IsLogJSON returns if we should log json format (as set via config file or environment variable).

func (*Config) IsTestingMode

func (c *Config) IsTestingMode() bool

IsTestingMode returns if the service runs in unit-tests environment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL