mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #32510 from hashicorp/jbardin/terraform-data-typed-null
typed null input should be reflected in output
This commit is contained in:
commit
b9fc2d62d1
@ -74,8 +74,10 @@ func planDataStoreResourceChange(req providers.PlanResourceChangeRequest) (resp
|
||||
// Set the id value to unknown.
|
||||
planned["id"] = cty.UnknownVal(cty.String)
|
||||
|
||||
// Only compute a new output if input has a non-null value.
|
||||
if !input.IsNull() {
|
||||
// Output type must always match the input, even when it's null.
|
||||
if input.IsNull() {
|
||||
planned["output"] = input
|
||||
} else {
|
||||
planned["output"] = cty.UnknownVal(input.Type())
|
||||
}
|
||||
|
||||
@ -90,7 +92,7 @@ func planDataStoreResourceChange(req providers.PlanResourceChangeRequest) (resp
|
||||
// We need to check the input for the replacement instance to compute a
|
||||
// new output.
|
||||
if input.IsNull() {
|
||||
planned["output"] = cty.NullVal(cty.DynamicPseudoType)
|
||||
planned["output"] = input
|
||||
} else {
|
||||
planned["output"] = cty.UnknownVal(input.Type())
|
||||
}
|
||||
|
@ -125,6 +125,22 @@ func TestManagedDataPlan(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
|
||||
"create-typed-null-input": {
|
||||
prior: cty.NullVal(ty),
|
||||
proposed: cty.ObjectVal(map[string]cty.Value{
|
||||
"input": cty.NullVal(cty.String),
|
||||
"output": cty.NullVal(cty.DynamicPseudoType),
|
||||
"triggers_replace": cty.NullVal(cty.DynamicPseudoType),
|
||||
"id": cty.NullVal(cty.String),
|
||||
}),
|
||||
planned: cty.ObjectVal(map[string]cty.Value{
|
||||
"input": cty.NullVal(cty.String),
|
||||
"output": cty.NullVal(cty.String),
|
||||
"triggers_replace": cty.NullVal(cty.DynamicPseudoType),
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
}),
|
||||
},
|
||||
|
||||
"create-output": {
|
||||
prior: cty.NullVal(ty),
|
||||
proposed: cty.ObjectVal(map[string]cty.Value{
|
||||
|
Loading…
Reference in New Issue
Block a user