Merge pull request #29411 from hashicorp/jbardin/plan-nesting-single
handle null NestingSingle values
This commit is contained in:
commit
9f24b4dc68
|
@ -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