Documentation ¶
Overview ¶
Package config loads configuation objects and provides thin wrappers for interpreting them. It reads a search path from the CONFIG_PATH environment variable. All files found along the search path are read and cached and are accessible by file name.
Currently, the config package does not support recursive searching; directories found on the search path are ignored.
Index ¶
- Constants
- Variables
- func Bytes(n string) ([]byte, error)
- func InterfaceJson(n string, v interface{}) error
- func InterfaceYaml(n string, v interface{}) error
- func IsKubernetes() bool
- func Load() error
- func Path() string
- func String(n string) (string, error)
- func Url(n string) (*url.URL, error)
- func Userinfo(n string) (*url.Userinfo, error)
Constants ¶
const EnvVar = "CONFIG_PATH"
EnvVar is the name of the environment variable used to determine the config path. If it is provided, it will override the DefaultPath value.
Variables ¶
var DefaultPath string
DefaultPath is the fallback config path if CONFIG_PATH is not defined. It is "/etc/config" if IsKubernetes(). Otherwise, it is "./config".
Functions ¶
func Bytes ¶ added in v0.0.6
Bytes calls Load() then returns the data for the configuration value named n.
func InterfaceJson ¶ added in v0.0.13
InterfaceJson calls json.Unmarshal() on Bytes(n)
func InterfaceYaml ¶ added in v0.0.14
InterfaceYaml calls yaml.Unmarshal() on Bytes(n)
func IsKubernetes ¶ added in v0.0.15
func IsKubernetes() bool
IsKubernetes determines if we are running in a kubernetes cluster. It checks for the presence of the KUBERNETES_SERVICE_HOST environment variable.
func Load ¶
func Load() error
Load loads the configuration into memory. After it has been called once, calling it again will have no effect.
func Path ¶ added in v0.0.6
func Path() string
Path returns the configuration path value pointed to by EnvVar or DefaultPath.
Types ¶
This section is empty.