Skip to content

Commit

Permalink
NodeDestroyResource needs to be referencable
Browse files Browse the repository at this point in the history
The change in #23696 removed the NodeAbstractResource methods from the
NodeDestroyResource type, in order to prevent other resource behaviors,
like requesting a provider.

While this node type is not directly referenced, it was implicitly
ordered against the module cleanup by virtue of being a resource node.
The ReferenceTransformer uses the GraphNodeReferenceable and
GraphNodeSubPath interfaces to add nodes to the reference map, so we
need to re-add the relevant methods.

Since there's no good entry point to test this ordering at the moment,
  • Loading branch information
jbardin committed Jan 9, 2020
1 parent b6a041a commit a2cbd40
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions terraform/node_resource_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,29 @@ type NodeDestroyResource struct {

var (
_ GraphNodeEvalable = (*NodeDestroyResource)(nil)
// TransformReferences looks for indirect references as well, and relies
// on these two interfaces to connect them. This ensures the node is
// evaluated before the corresponding NodeModuleRemoved.
_ GraphNodeReferenceable = (*NodeDestroyResource)(nil)
_ GraphNodeSubPath = (*NodeDestroyResource)(nil)
)

func (n *NodeDestroyResource) Name() string {
return n.NodeAbstractResource.ResourceAddr().String() + " (clean up state)"
}

// NodeDestroyResource still needs to be a GraphNodeReferenceable so that a
// NodeModuleRemoved can reference it for cleanup.
func (n *NodeDestroyResource) ReferenceableAddrs() []addrs.Referenceable {
return n.NodeAbstractResource.ReferenceableAddrs()
}

// NodeDestroyResource still needs to be a GraphNodeSubPath so that a
// NodeModuleRemoved can reference it for cleanup.
func (n *NodeDestroyResource) Path() addrs.ModuleInstance {
return n.NodeAbstractResource.Path()
}

// GraphNodeEvalable
func (n *NodeDestroyResource) EvalTree() EvalNode {
// This EvalNode will produce an error if the resource isn't already
Expand Down

0 comments on commit a2cbd40

Please sign in to comment.