Merge pull request #12507 from hashicorp/jbardin/config-crash

nested lists in variables panic during validation
This commit is contained in:
James Bardin 2017-03-09 09:00:20 -05:00 committed by GitHub
commit 7d5963e6e1
3 changed files with 18 additions and 0 deletions

View File

@ -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 {

View File

@ -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:

View File

@ -0,0 +1,6 @@
variable "foo" {
default = [["foo", "bar"]]
}
variable "bar" {
default = [{foo = "bar"}]
}