mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-12 09:01:58 -06:00
core: don't force data resource id diff to be empty
In an attempt to always show "id" as computed we were producing a synthetic diff for it, but this causes problems when the id attribute for a particular data source is actually settable in configuration, since it masks the setting from the config and forces it to always be empty. Instead, we'll set it conditionally so that a value provided in the config can shine through when available.
This commit is contained in:
parent
7d2b51e6c5
commit
ab29eca045
@ -47,14 +47,17 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) {
|
||||
diff = new(InstanceDiff)
|
||||
}
|
||||
|
||||
// id is always computed, because we're always "creating a new resource"
|
||||
// if id isn't explicitly set then it's always computed, because we're
|
||||
// always "creating a new resource".
|
||||
diff.init()
|
||||
diff.SetAttribute("id", &ResourceAttrDiff{
|
||||
Old: "",
|
||||
NewComputed: true,
|
||||
RequiresNew: true,
|
||||
Type: DiffAttrOutput,
|
||||
})
|
||||
if _, ok := diff.Attributes["id"]; !ok {
|
||||
diff.SetAttribute("id", &ResourceAttrDiff{
|
||||
Old: "",
|
||||
NewComputed: true,
|
||||
RequiresNew: true,
|
||||
Type: DiffAttrOutput,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
err = ctx.Hook(func(h Hook) (HookAction, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user