Merge pull request #12507 from hashicorp/jbardin/config-crash
nested lists in variables panic during validation
This commit is contained in:
commit
7d5963e6e1
|
@ -201,6 +201,12 @@ func TestConfigValidate_table(t *testing.T) {
|
|||
true,
|
||||
"cannot contain interp",
|
||||
},
|
||||
{
|
||||
"nested types in variable default",
|
||||
"validate-var-nested",
|
||||
false,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
|
|
@ -206,6 +206,12 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
|
|||
}
|
||||
|
||||
func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
|
||||
// if we don't have at least 2 values, we're not going to find a map, but
|
||||
// we could panic.
|
||||
if len(w.cs) < 2 {
|
||||
return
|
||||
}
|
||||
|
||||
c := w.cs[len(w.cs)-2]
|
||||
switch c.Kind() {
|
||||
case reflect.Map:
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
variable "foo" {
|
||||
default = [["foo", "bar"]]
|
||||
}
|
||||
variable "bar" {
|
||||
default = [{foo = "bar"}]
|
||||
}
|
Loading…
Reference in New Issue