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) {
case map[string]interface{}:
m2 = val.(map[string]interface{})
case []interface{}:
m2 = cast.ToStringMap(val)
case map[interface{}]interface{}:
m2 = cast.ToStringMap(val)
default:

11
util.go
View file

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