diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-04-09 12:16:11 -0400 |
---|---|---|
committer | Jesús Espino <jespinog@gmail.com> | 2018-04-09 18:16:11 +0200 |
commit | 0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7 (patch) | |
tree | 4b46ef4dc50aed2171d3b5ec38117a148db7ae29 /vendor/github.com | |
parent | 57ee6f505e1b231733dc73dc25d2fbe14bd6b7d5 (diff) | |
download | chat-0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7.tar.gz chat-0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7.tar.bz2 chat-0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7.zip |
MM-9849 Added tracking of which settings are set through environment variables (#8586)
* MM-9849 Added tracking of which settings are set through environment variables
* Removed old version of viper
* Added forked version of viper
* Fixed unit tests
* Fixed more unit tests
* Removed copy from App.GetEnvironmentConfig
Diffstat (limited to 'vendor/github.com')
-rw-r--r-- | vendor/github.com/spf13/viper/nohup.out | 1 | ||||
-rw-r--r-- | vendor/github.com/spf13/viper/viper.go | 38 |
2 files changed, 27 insertions, 12 deletions
diff --git a/vendor/github.com/spf13/viper/nohup.out b/vendor/github.com/spf13/viper/nohup.out deleted file mode 100644 index 8973bf27b..000000000 --- a/vendor/github.com/spf13/viper/nohup.out +++ /dev/null @@ -1 +0,0 @@ -QProcess::start: Process is already running diff --git a/vendor/github.com/spf13/viper/viper.go b/vendor/github.com/spf13/viper/viper.go index ad8a03729..b9e165695 100644 --- a/vendor/github.com/spf13/viper/viper.go +++ b/vendor/github.com/spf13/viper/viper.go @@ -1675,6 +1675,26 @@ func (v *Viper) AllSettings() map[string]interface{} { return m } +// EnvSettings returns a map[string]interface{} containing all settings set +// through environment variables. +func EnvSettings() map[string]interface{} { return v.EnvSettings() } +func (v *Viper) EnvSettings() map[string]interface{} { + m := map[string]interface{}{} + // start from the list of keys, and construct the map one value at a time + for _, k := range v.AllKeys() { + value := v.getEnv(v.mergeWithEnvPrefix(k)) + if value == "" { + continue + } + path := strings.Split(k, v.keyDelim) + lastKey := strings.ToLower(path[len(path)-1]) + deepestMap := deepSearch(m, path[0:len(path)-1]) + // set innermost value + deepestMap[lastKey] = true + } + return m +} + // SetFs sets the filesystem to use to read configuration. func SetFs(fs afero.Fs) { v.SetFs(fs) } func (v *Viper) SetFs(fs afero.Fs) { @@ -1720,18 +1740,14 @@ func (v *Viper) getConfigType() string { } func (v *Viper) getConfigFile() (string, error) { - // if explicitly set, then use it - if v.configFile != "" { - return v.configFile, nil - } - - cf, err := v.findConfigFile() - if err != nil { - return "", err + if v.configFile == "" { + cf, err := v.findConfigFile() + if err != nil { + return "", err + } + v.configFile = cf } - - v.configFile = cf - return v.getConfigFile() + return v.configFile, nil } func (v *Viper) searchInPath(in string) (filename string) { |