config: removeCurrent finds the proper map
This commit is contained in:
parent
3aa655ad3b
commit
a931707a6a
|
@ -195,7 +195,11 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
|
|||
}
|
||||
|
||||
func (w *interpolationWalker) removeCurrent() {
|
||||
c := w.cs[len(w.cs)-1]
|
||||
// Append the key to the unknown keys
|
||||
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
|
||||
|
@ -204,10 +208,11 @@ func (w *interpolationWalker) removeCurrent() {
|
|||
// Get the key and delete it
|
||||
k := w.csData.(reflect.Value)
|
||||
c.SetMapIndex(k, val)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Append the key to the unknown keys
|
||||
w.unknownKeys = append(w.unknownKeys, strings.Join(w.key, "."))
|
||||
panic("No container found for removeCurrent")
|
||||
}
|
||||
|
||||
func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
|
||||
|
|
|
@ -188,6 +188,17 @@ func TestInterpolationWalker_replace(t *testing.T) {
|
|||
},
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue