core: Ensure EvalReadDataApply is called on expanded destroy nodes
During accpeptance tests of some of the first data sources (see hashicorp/terraform#6881 and hashicorp/terraform#6911), "unknown resource type" errors have been coming up. Traced it down to the ResourceCountTransformer, which transforms destroy nodes to a graphNodeExpandedResourceDestroy node. This node's EvalTree() was still indiscriminately using EvalApply for all resource types, versus EvalReadDataApply. This accounts for both cases via EvalIf.
This commit is contained in:
parent
a3a8b534ed
commit
559799599e
|
@ -894,13 +894,30 @@ func (n *graphNodeExpandedResourceDestroy) EvalTree() EvalNode {
|
|||
&EvalRequireState{
|
||||
State: &state,
|
||||
},
|
||||
&EvalApply{
|
||||
Info: info,
|
||||
State: &state,
|
||||
Diff: &diffApply,
|
||||
Provider: &provider,
|
||||
Output: &state,
|
||||
Error: &err,
|
||||
// Make sure we handle data sources properly.
|
||||
&EvalIf{
|
||||
If: func(ctx EvalContext) (bool, error) {
|
||||
if n.Resource.Mode == config.DataResourceMode {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
},
|
||||
|
||||
Then: &EvalReadDataApply{
|
||||
Info: info,
|
||||
Diff: &diffApply,
|
||||
Provider: &provider,
|
||||
Output: &state,
|
||||
},
|
||||
Else: &EvalApply{
|
||||
Info: info,
|
||||
State: &state,
|
||||
Diff: &diffApply,
|
||||
Provider: &provider,
|
||||
Output: &state,
|
||||
Error: &err,
|
||||
},
|
||||
},
|
||||
&EvalWriteState{
|
||||
Name: n.stateId(),
|
||||
|
|
Loading…
Reference in New Issue