Revert the effective changes of #673

This commit is contained in:
Mark Sagi-Kazar 2019-09-27 17:18:11 +02:00 committed by Márk Sági-Kazár
parent 398adc5a7d
commit 71509d2887
2 changed files with 2 additions and 36 deletions

View file

@ -1789,24 +1789,6 @@ outer:
return shadow
}
// Converts a fully qualified map key into a list of relative
// map keys, allowing for keys to contain the delimiter themselves
func keyComponents(v *Viper, key string) []string {
var result []string
components := strings.Split(key, v.keyDelim)
for index := 0; index < len(components); index++ {
potentialKey := strings.Join(components[0:index], v.keyDelim)
if v.Get(potentialKey) != nil {
result = append(result, potentialKey)
}
}
result = append(result, key)
for i := len(result) - 1; i > 0; i-- {
result[i] = strings.Replace(result[i], result[i-1]+v.keyDelim, "", 1)
}
return result
}
// AllSettings merges all settings and returns them as a map[string]interface{}.
func AllSettings() map[string]interface{} { return v.AllSettings() }
func (v *Viper) AllSettings() map[string]interface{} {
@ -1819,7 +1801,7 @@ func (v *Viper) AllSettings() map[string]interface{} {
// check just in case anything changes
continue
}
path := keyComponents(v, k)
path := strings.Split(k, v.keyDelim)
lastKey := strings.ToLower(path[len(path)-1])
deepestMap := deepSearch(m, path[0:len(path)-1])
// set innermost value

View file

@ -46,10 +46,6 @@ clothing:
age: 35
eyes : brown
beard: true
emails:
steve@hacker.com:
created: 01/02/03
active: true
`)
var yamlExampleWithExtras = []byte(`Existing: true
@ -535,8 +531,6 @@ func TestAllKeys(t *testing.T) {
"title_dotenv",
"type_dotenv",
"name_dotenv",
"emails.steve@hacker.com.active",
"emails.steve@hacker.com.created",
}
dob, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z")
all := map[string]interface{}{
@ -547,12 +541,6 @@ func TestAllKeys(t *testing.T) {
},
"title": "TOML Example",
"ppu": 0.55,
"emails": map[string]interface{}{
"steve@hacker.com": map[string]interface{}{
"active": true,
"created": "01/02/03",
},
},
"eyes": "brown",
"clothing": map[string]interface{}{
"trousers": "denim",
@ -1316,10 +1304,6 @@ clothing:
pants:
size: large
trousers: denim
emails:
steve@hacker.com:
active: true
created: 01/02/03
eyes: brown
hacker: true
hobbies: