Skip to content

Commit

Permalink
Revert the effective changes of #673
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Sep 27, 2019
1 parent e5833fa commit 141d214
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
20 changes: 1 addition & 19 deletions viper.go
Expand Up @@ -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{} {
Expand All @@ -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
Expand Down
18 changes: 1 addition & 17 deletions viper_test.go
Expand Up @@ -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
Expand Down Expand Up @@ -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{}{
Expand All @@ -547,13 +541,7 @@ 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",
"eyes": "brown",
"clothing": map[string]interface{}{
"trousers": "denim",
"jacket": "leather",
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 141d214

Please sign in to comment.