Skip to content

Commit

Permalink
core: Ensure EvalReadDataApply is called on expanded destroy nodes
Browse files Browse the repository at this point in the history
During accpeptance tests of some of the first data sources (see
hashicorp#6881 and hashicorp#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.
  • Loading branch information
Chris Marchesi committed May 29, 2016
1 parent a3a8b53 commit 5597995
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions terraform/transform_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 5597995

Please sign in to comment.