Documentation ¶
Overview ¶
Package config allows a struct-loading approach to configuration. This is a modified version of the ucpconfig package
Index ¶
- Variables
- func Load(intf interface{}, envLookup env.Lookup) error
- func NewConfigFileLookup(path string) env.Lookup
- func NewSecretsDirLookup(secretsDir string) env.Lookup
- func SetStructFieldValue(value reflect.Value, field reflect.Value, val string) error
- type APIKeysConfigValue
- type UserEndpointsConfigValue
Constants ¶
This section is empty.
Variables ¶
var APIKeysConfigEnum = struct { Disabled APIKeysConfigValue AdminOnly APIKeysConfigValue AllUsers APIKeysConfigValue }{ Disabled: "disabled", AdminOnly: "admin_only", AllUsers: "all_users", }
APIKeysConfigEnum - defines possible configuration values for Stratos API keys feature
var UserEndpointsConfigEnum = struct { Disabled UserEndpointsConfigValue AdminOnly UserEndpointsConfigValue Enabled UserEndpointsConfigValue }{ Disabled: "disabled", AdminOnly: "admin_only", Enabled: "enabled", }
UserEndpointsConfigEnum - defines possible configuration values for Stratos user endpoints feature
Functions ¶
func Load ¶
Load the given pointer to struct with values from the environment and the /etc/secrets/ directory.
In order to make the struct load correctly, use struct tags to define the configuration name, if the configName struct tag is ommitted it will not attempt to look anything up. This is contrary to most serialization libraries like JSON which require a "-" struct tag to bypass deserialization.
type A struct { Port uint `configName:"PORT"` Name string `configName:"SERVICE_NAME"` Struct *myType }
The name will be given as defined to Getenv, and if that fails a lookup it's name is then munged to conform to the /etc/secrets filename structure and the file is attempted to be read.
func NewConfigFileLookup ¶
NewConfigFileLookup - Load the configuration values in the specified config file if it exists
func NewSecretsDirLookup ¶
NewSecretsDirLookup - create a secret dir lookup reads a variable in the form HELLO_THERE from a file in /etc/secrets/hello-there
Types ¶
type APIKeysConfigValue ¶
type APIKeysConfigValue string
APIKeysConfigValue - special type for configuring whether API keys feature is enabled
type UserEndpointsConfigValue ¶
type UserEndpointsConfigValue string
UserEndpointsConfigValue - special type for configuring whether user endpoints feature is enabled