handle null NestingSingle values
Null NestingSingle attributes were not being handled in ProposedNew
This commit is contained in:
parent
c351f41e47
commit
da007517b0
|
@ -311,8 +311,11 @@ func proposedNewNestedType(schema *configschema.Object, prior, config cty.Value)
|
|||
var newV cty.Value
|
||||
switch schema.Nesting {
|
||||
case configschema.NestingSingle:
|
||||
newAttrs := proposedNewAttributes(schema.Attributes, prior, config)
|
||||
newV = cty.ObjectVal(newAttrs)
|
||||
if !config.IsNull() {
|
||||
newV = cty.ObjectVal(proposedNewAttributes(schema.Attributes, prior, config))
|
||||
} else {
|
||||
newV = cty.NullVal(config.Type())
|
||||
}
|
||||
|
||||
case configschema.NestingList:
|
||||
// Nested blocks are correlated by index.
|
||||
|
|
|
@ -1433,7 +1433,7 @@ func TestProposedNew(t *testing.T) {
|
|||
}),
|
||||
}),
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"single": cty.ObjectVal(map[string]cty.Value{"bar": cty.NullVal(cty.String)}),
|
||||
"single": cty.NullVal(cty.Object(map[string]cty.Type{"bar": cty.String})),
|
||||
"list": cty.NullVal(cty.List(cty.Object(map[string]cty.Type{"bar": cty.String}))),
|
||||
"map": cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"bar": cty.String}))),
|
||||
"set": cty.NullVal(cty.Set(cty.Object(map[string]cty.Type{"bar": cty.String}))),
|
||||
|
@ -1447,7 +1447,7 @@ func TestProposedNew(t *testing.T) {
|
|||
}))),
|
||||
}),
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"single": cty.ObjectVal(map[string]cty.Value{"bar": cty.NullVal(cty.String)}),
|
||||
"single": cty.NullVal(cty.Object(map[string]cty.Type{"bar": cty.String})),
|
||||
"list": cty.NullVal(cty.List(cty.Object(map[string]cty.Type{"bar": cty.String}))),
|
||||
"map": cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"bar": cty.String}))),
|
||||
"set": cty.NullVal(cty.Set(cty.Object(map[string]cty.Type{"bar": cty.String}))),
|
||||
|
|
Loading…
Reference in New Issue