config: removeCurrent finds the proper map
This commit is contained in:
parent
3aa655ad3b
commit
a931707a6a
|
@ -195,19 +195,24 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *interpolationWalker) removeCurrent() {
|
func (w *interpolationWalker) removeCurrent() {
|
||||||
c := w.cs[len(w.cs)-1]
|
|
||||||
switch c.Kind() {
|
|
||||||
case reflect.Map:
|
|
||||||
// Zero value so that we delete the map key
|
|
||||||
var val reflect.Value
|
|
||||||
|
|
||||||
// Get the key and delete it
|
|
||||||
k := w.csData.(reflect.Value)
|
|
||||||
c.SetMapIndex(k, val)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append the key to the unknown keys
|
// Append the key to the unknown keys
|
||||||
w.unknownKeys = append(w.unknownKeys, strings.Join(w.key, "."))
|
w.unknownKeys = append(w.unknownKeys, strings.Join(w.key, "."))
|
||||||
|
|
||||||
|
for i := 1; i <= len(w.cs); i++ {
|
||||||
|
c := w.cs[len(w.cs)-i]
|
||||||
|
switch c.Kind() {
|
||||||
|
case reflect.Map:
|
||||||
|
// Zero value so that we delete the map key
|
||||||
|
var val reflect.Value
|
||||||
|
|
||||||
|
// Get the key and delete it
|
||||||
|
k := w.csData.(reflect.Value)
|
||||||
|
c.SetMapIndex(k, val)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("No container found for removeCurrent")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
|
func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
|
||||||
|
|
|
@ -188,6 +188,17 @@ func TestInterpolationWalker_replace(t *testing.T) {
|
||||||
},
|
},
|
||||||
Value: "bar" + InterpSplitDelim + "baz",
|
Value: "bar" + InterpSplitDelim + "baz",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
Input: map[string]interface{}{
|
||||||
|
"foo": []interface{}{
|
||||||
|
"${var.foo}",
|
||||||
|
"bing",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Output: map[string]interface{}{},
|
||||||
|
Value: UnknownVariableValue + InterpSplitDelim + "baz",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range cases {
|
for i, tc := range cases {
|
||||||
|
|
Loading…
Reference in New Issue