Documentation ¶
Index ¶
Constants ¶
const (
DefaultFileName = "config.yaml"
)
Variables ¶
var (
DecoderHook = viper.DecodeHook(mapstructure.TextUnmarshallerHookFunc())
)
Functions ¶
func GenerateNodeID ¶ added in v1.5.0
func KeyAsEnvVar ¶ added in v1.0.4
KeyAsEnvVar returns the environment variable corresponding to a config key
Types ¶
type Config ¶ added in v1.5.0
type Config struct {
// contains filtered or unexported fields
}
func New ¶ added in v1.3.2
New returns a configuration with the provided options applied. If no options are provided, the returned config contains only the default values.
func (*Config) ConfigFileUsed ¶ added in v1.5.0
func (*Config) Load ¶ added in v1.5.0
Load reads in the configuration file specified by `path` overriding any previously set configuration with the values from the read config file. Load returns an error if the file cannot be read.
func (*Config) Merge ¶
Merge merges a new configuration file specified by `path` with the existing config. Merge returns an error if the file cannot be read
type Option ¶ added in v1.1.5
type Option = func(s *Config)
func WithDefault ¶ added in v1.5.0
func WithDefault(cfg interface{}) Option
WithDefault sets the default config to be used when no values are provided.
func WithEnvironmentVariables ¶ added in v1.5.0
func WithPaths ¶ added in v1.5.0
WithPaths sets paths to configuration files to be loaded paths to configuration files merged from [0] to [N] e.g. file at index 1 overrides index 0, index 2 overrides index 1 and 0, etc.
func WithValues ¶ added in v1.5.0
WithValues sets values to be injected into the config, taking precedence over all other options.