Fix broken tests

This commit is contained in:
Fabio Mangione 2022-03-24 12:28:00 +00:00
parent cd03c57ee4
commit 7956726f5e
2 changed files with 8 additions and 5 deletions

View file

@ -60,6 +60,8 @@ func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{},
switch val.(type) { switch val.(type) {
case map[string]interface{}: case map[string]interface{}:
m2 = val.(map[string]interface{}) m2 = val.(map[string]interface{})
case []interface{}:
m2 = cast.ToStringMap(val)
case map[interface{}]interface{}: case map[interface{}]interface{}:
m2 = cast.ToStringMap(val) m2 = cast.ToStringMap(val)
default: default:

11
util.go
View file

@ -190,12 +190,13 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{}
m = m3 m = m3
continue continue
} }
m3, ok := m2.(map[string]interface{}) m3, isMap := m2.(map[string]interface{})
if !ok { if !isMap {
// intermediate key is a value // in case the intermediate value is not a map
// => replace with a new map // a slice with previous value and a new map gets created
m3 = make(map[string]interface{}) m3 = make(map[string]interface{})
m[k] = m3 mixedValue := []interface{}{m2, m3}
m[k] = mixedValue
} }
// continue search from here // continue search from here
m = m3 m = m3