mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
core: restore data resource creation diffs
cd0c452
contained a bug where the creation diff for a data resource was
put into a new local variable within the else block rather than into the
diff variable in the parent scope, causing a null diff to always be
produced.
This restores the expected behavior: a computed data resource appears in
the diff, so it can then be fetched during the apply walk.
This commit is contained in:
parent
d9c137555f
commit
b255c389e2
@ -889,10 +889,26 @@ func TestContext2Plan_computedDataResource(t *testing.T) {
|
||||
if _, ok := moduleDiff.Resources["aws_instance.foo"]; !ok {
|
||||
t.Fatalf("missing diff for aws_instance.foo")
|
||||
}
|
||||
_, ok := moduleDiff.Resources["data.aws_vpc.bar"]
|
||||
iDiff, ok := moduleDiff.Resources["data.aws_vpc.bar"]
|
||||
if !ok {
|
||||
t.Fatalf("missing diff for data.aws_vpc.bar")
|
||||
}
|
||||
|
||||
expectedDiff := &InstanceDiff{
|
||||
Attributes: map[string]*ResourceAttrDiff{
|
||||
"id": {
|
||||
NewComputed: true,
|
||||
RequiresNew: true,
|
||||
Type: DiffAttrOutput,
|
||||
},
|
||||
},
|
||||
}
|
||||
if same, _ := expectedDiff.Same(iDiff); !same {
|
||||
t.Fatalf(
|
||||
"incorrect diff for data.aws_vpc.bar\ngot: %#v\nwant: %#v",
|
||||
iDiff, expectedDiff,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Plan_computedList(t *testing.T) {
|
||||
|
@ -38,7 +38,8 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) {
|
||||
provider := *n.Provider
|
||||
config := *n.Config
|
||||
|
||||
diff, err := provider.ReadDataDiff(n.Info, config)
|
||||
var err error
|
||||
diff, err = provider.ReadDataDiff(n.Info, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user