Skip to content

Commit da00751

Browse files
committed
handle null NestingSingle values
Null NestingSingle attributes were not being handled in ProposedNew
1 parent c351f41 commit da00751

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

internal/plans/objchange/objchange.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,11 @@ func proposedNewNestedType(schema *configschema.Object, prior, config cty.Value)
311311
var newV cty.Value
312312
switch schema.Nesting {
313313
case configschema.NestingSingle:
314-
newAttrs := proposedNewAttributes(schema.Attributes, prior, config)
315-
newV = cty.ObjectVal(newAttrs)
314+
if !config.IsNull() {
315+
newV = cty.ObjectVal(proposedNewAttributes(schema.Attributes, prior, config))
316+
} else {
317+
newV = cty.NullVal(config.Type())
318+
}
316319

317320
case configschema.NestingList:
318321
// Nested blocks are correlated by index.

internal/plans/objchange/objchange_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ func TestProposedNew(t *testing.T) {
14331433
}),
14341434
}),
14351435
cty.ObjectVal(map[string]cty.Value{
1436-
"single": cty.ObjectVal(map[string]cty.Value{"bar": cty.NullVal(cty.String)}),
1436+
"single": cty.NullVal(cty.Object(map[string]cty.Type{"bar": cty.String})),
14371437
"list": cty.NullVal(cty.List(cty.Object(map[string]cty.Type{"bar": cty.String}))),
14381438
"map": cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"bar": cty.String}))),
14391439
"set": cty.NullVal(cty.Set(cty.Object(map[string]cty.Type{"bar": cty.String}))),
@@ -1447,7 +1447,7 @@ func TestProposedNew(t *testing.T) {
14471447
}))),
14481448
}),
14491449
cty.ObjectVal(map[string]cty.Value{
1450-
"single": cty.ObjectVal(map[string]cty.Value{"bar": cty.NullVal(cty.String)}),
1450+
"single": cty.NullVal(cty.Object(map[string]cty.Type{"bar": cty.String})),
14511451
"list": cty.NullVal(cty.List(cty.Object(map[string]cty.Type{"bar": cty.String}))),
14521452
"map": cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"bar": cty.String}))),
14531453
"set": cty.NullVal(cty.Set(cty.Object(map[string]cty.Type{"bar": cty.String}))),

0 commit comments

Comments
 (0)