Merge pull request #21882 from hashicorp/jbardin/obj-compat-panic

actual value may be unknown in nested list
This commit is contained in:
James Bardin 2019-06-25 18:08:09 -04:00 committed by GitHub
commit 6eb40f846b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -84,7 +84,7 @@ func assertObjectCompatible(schema *configschema.Block, planned, actual cty.Valu
// whether there are dynamically-typed attributes inside. However,
// both support a similar-enough API that we can treat them the
// same for our purposes here.
if !plannedV.IsKnown() || plannedV.IsNull() || actualV.IsNull() {
if !plannedV.IsKnown() || !actualV.IsKnown() || plannedV.IsNull() || actualV.IsNull() {
continue
}

View File

@ -1135,6 +1135,32 @@ func TestAssertObjectCompatible(t *testing.T) {
}),
nil,
},
{
&configschema.Block{
BlockTypes: map[string]*configschema.NestedBlock{
"block": {
Nesting: configschema.NestingList,
Block: configschema.Block{
Attributes: map[string]*configschema.Attribute{
"foo": {
Type: cty.String,
Required: true,
},
},
},
},
},
},
cty.ObjectVal(map[string]cty.Value{
"block": cty.EmptyObjectVal,
}),
cty.ObjectVal(map[string]cty.Value{
"block": cty.UnknownVal(cty.List(cty.Object(map[string]cty.Type{
"foo": cty.String,
}))),
}),
nil,
},
}
for i, test := range tests {