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
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
57ee6f505e
Коммит
0a6b96cb40
1
vendor/github.com/spf13/viper/nohup.out
сгенерированный
поставляемый
1
vendor/github.com/spf13/viper/nohup.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
QProcess::start: Process is already running
|
||||
38
vendor/github.com/spf13/viper/viper.go
сгенерированный
поставляемый
38
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
|
||||
if v.configFile == "" {
|
||||
cf, err := v.findConfigFile()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
v.configFile = cf
|
||||
}
|
||||
|
||||
cf, err := v.findConfigFile()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
v.configFile = cf
|
||||
return v.getConfigFile()
|
||||
return v.configFile, nil
|
||||
}
|
||||
|
||||
func (v *Viper) searchInPath(in string) (filename string) {
|
||||
|
||||
Ссылка в новой задаче
Block a user