diff options
author | Valery Piashchynski <[email protected]> | 2020-10-19 14:01:59 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-10-19 14:01:59 +0300 |
commit | 77670fb7af0c892c9b3a589fd424534fad288e7a (patch) | |
tree | 3adcaa85db664a355abe2b28f1d7e4a3fc45689f /plugins/config/viper.go | |
parent | 16fbf3104c3c34bd9355593052b686acd26a8efe (diff) |
Update according activity worker
Diffstat (limited to 'plugins/config/viper.go')
-rw-r--r-- | plugins/config/viper.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/config/viper.go b/plugins/config/viper.go index 0362e79b..b276dbe2 100644 --- a/plugins/config/viper.go +++ b/plugins/config/viper.go @@ -17,17 +17,21 @@ type ViperProvider struct { //////// ENDURE ////////// func (v *ViperProvider) Init() error { v.viper = viper.New() + // read in environment variables that match v.viper.AutomaticEnv() if v.Prefix == "" { return errors.New("prefix should be set") } + v.viper.SetEnvPrefix(v.Prefix) if v.Path == "" { return errors.New("path should be set") } + v.viper.SetConfigFile(v.Path) v.viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + return v.viper.ReadInConfig() } @@ -62,6 +66,11 @@ func (v *ViperProvider) Get(name string) interface{} { return v.viper.Get(name) } +// Has checks if config section exists. +func (v *ViperProvider) Has(name string) bool { + return v.viper.IsSet(name) +} + /////////// PRIVATE ////////////// func parseFlag(flag string) (string, string, error) { |