Documentation ¶
Overview ¶
Package configuration groups all configuration related utilities
Index ¶
Constants ¶
const EnvConfigServerEnvironment string = "CONFIGSERVER_ENV"
EnvConfigServerEnvironment holds the name of the environment variable storing the current active environment type (dev, int, prod ...)
const EnvConfigServerHome string = "CONFIGSERVER_HOME"
EnvConfigServerHome holds the path to the directory containing the application's config
Variables ¶
var DefaultConfiguration = &Configuration{ Environment: &Environment{ Kind: "production", Home: "/var/run/configserver", }, Server: &Server{ PassPhrase: "This is a default passphrase and should be changed", ListenOn: ":4200", SecretExpiryDays: 365, ValidateSecretLifeSpan: false, }, Repositories: &Repositories{ CheckoutLocation: "", }, }
DefaultConfiguration for when its needed
Functions ¶
func InitLogging ¶
func InitLogging()
InitLogging sets up logging based on the CONFIGSERVER_ENV environment variable. JSON based logging will be automatically enabled if the environment name does not contain the "dev" substring
Types ¶
type Configuration ¶
type Configuration struct { Source string // Environment variables for ease of use *Environment // Server related settings *Server // Repositories configuration *Repositories }
Configuration groups all the supported configuration options
func LoadFrom ¶
func LoadFrom(path string) (*Configuration, error)
LoadFrom loads the configuration file from the provided path This method always return a Configuration object with at least the Environment configuration loaded
func (*Configuration) LogEnvironment ¶
func (c *Configuration) LogEnvironment()
LogEnvironment logs the current environment configuration
type Environment ¶
type Environment struct { Kind string // environment kind i,e dev, int, prod Home string // path to the directory containing configserver configuration files }
Environment gathers all the environment variable used by ConfigServer
type Repositories ¶
type Repositories struct { CheckoutLocation string `yaml:"checkoutLocation"` // Folder to which the repositories are stored Configuration []*Repository `yaml:"configuration"` // Collection of git repositories configuration }
Repositories materializes the GIT repositories configuration
type Repository ¶
type Repository struct { Name string `yaml:"name"` URL string `yaml:"url"` Branch string `yaml:"branch"` RefreshIntervalSeconds int `yaml:"refreshIntervalSeconds"` CheckoutLocation string `yaml:"checkoutLocation"` Token string `yaml:"token"` Clients []string `yaml:"clients"` }
Repository is a single GIT repository configuration
type Server ¶
type Server struct { PassPhrase string `yaml:"passPhrase"` // key used for secret encryption ListenOn string `yaml:"listenOn"` // address and port on which the server will listen for incoming requests SecretExpiryDays int `yaml:"secretExpiryDays"` // number of days after which a secret is considered as expired ValidateSecretLifeSpan bool `yaml:"validateSecretLifespan"` // if true, an expired secret will be considered invalid }
Server groups all the configserver related settings