mirror of
https://github.com/spf13/viper
synced 2025-05-05 19:57:18 +00:00
Key lookup searches v.override using path prefixes
When we assign to a map that uses urls for keys, we need to lookup values from that map in the same manner. Without doing so, `Get` will return inconsistent results. The agent codebase generally doesn't call `Get` this way, because we've known url keys work weird, but viper uses this type of call within AllSettings() in order to rebuild the config. In some cases, this could corrupt the data in the config.
This commit is contained in:
parent
89890a76de
commit
7d76daf975
1 changed files with 2 additions and 2 deletions
4
viper.go
4
viper.go
|
@ -1026,8 +1026,8 @@ func (v *Viper) find(lcaseKey string, skipDefault bool) interface{} {
|
|||
path = strings.Split(lcaseKey, v.keyDelim)
|
||||
nested = len(path) > 1
|
||||
|
||||
// Set() override first
|
||||
val = v.searchMap(v.override, path)
|
||||
// Set() writes to override, so check override first
|
||||
val = v.searchMapWithPathPrefixes(v.override, path)
|
||||
if val != nil {
|
||||
return val
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue