mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
builtin/providers/terraform: terraform_data "id" is guaranteed non-null
The "id" attribute of this resource type is generated by the provider itself and can never be null, so we'll refine the range of its unknown result in case that helps downstream expressions to produce known results even when the exact value hasn't yet been planned.
This commit is contained in:
parent
696cd68913
commit
691018dd00
@ -75,7 +75,7 @@ func planDataStoreResourceChange(req providers.PlanResourceChangeRequest) (resp
|
||||
case req.PriorState.IsNull():
|
||||
// Create
|
||||
// Set the id value to unknown.
|
||||
planned["id"] = cty.UnknownVal(cty.String)
|
||||
planned["id"] = cty.UnknownVal(cty.String).RefineNotNull()
|
||||
|
||||
// Output type must always match the input, even when it's null.
|
||||
if input.IsNull() {
|
||||
@ -90,7 +90,7 @@ func planDataStoreResourceChange(req providers.PlanResourceChangeRequest) (resp
|
||||
case !req.PriorState.GetAttr("triggers_replace").RawEquals(trigger):
|
||||
// trigger changed, so we need to replace the entire instance
|
||||
resp.RequiresReplace = append(resp.RequiresReplace, cty.GetAttrPath("triggers_replace"))
|
||||
planned["id"] = cty.UnknownVal(cty.String)
|
||||
planned["id"] = cty.UnknownVal(cty.String).RefineNotNull()
|
||||
|
||||
// We need to check the input for the replacement instance to compute a
|
||||
// new output.
|
||||
|
@ -124,7 +124,7 @@ func TestManagedDataPlan(t *testing.T) {
|
||||
"input": cty.NullVal(cty.DynamicPseudoType),
|
||||
"output": cty.NullVal(cty.DynamicPseudoType),
|
||||
"triggers_replace": cty.NullVal(cty.DynamicPseudoType),
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"id": cty.UnknownVal(cty.String).RefineNotNull(),
|
||||
}),
|
||||
},
|
||||
|
||||
@ -140,7 +140,7 @@ func TestManagedDataPlan(t *testing.T) {
|
||||
"input": cty.NullVal(cty.String),
|
||||
"output": cty.NullVal(cty.String),
|
||||
"triggers_replace": cty.NullVal(cty.DynamicPseudoType),
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"id": cty.UnknownVal(cty.String).RefineNotNull(),
|
||||
}),
|
||||
},
|
||||
|
||||
@ -156,7 +156,7 @@ func TestManagedDataPlan(t *testing.T) {
|
||||
"input": cty.StringVal("input"),
|
||||
"output": cty.UnknownVal(cty.String),
|
||||
"triggers_replace": cty.NullVal(cty.DynamicPseudoType),
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"id": cty.UnknownVal(cty.String).RefineNotNull(),
|
||||
}),
|
||||
},
|
||||
|
||||
@ -198,7 +198,7 @@ func TestManagedDataPlan(t *testing.T) {
|
||||
"input": cty.StringVal("input"),
|
||||
"output": cty.UnknownVal(cty.String),
|
||||
"triggers_replace": cty.StringVal("new-value"),
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"id": cty.UnknownVal(cty.String).RefineNotNull(),
|
||||
}),
|
||||
},
|
||||
|
||||
@ -225,7 +225,7 @@ func TestManagedDataPlan(t *testing.T) {
|
||||
"triggers_replace": cty.MapVal(map[string]cty.Value{
|
||||
"key": cty.StringVal("new value"),
|
||||
}),
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"id": cty.UnknownVal(cty.String).RefineNotNull(),
|
||||
}),
|
||||
},
|
||||
} {
|
||||
|
Loading…
Reference in New Issue
Block a user