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.

Since there's no good entry point to test this ordering at the moment,
  • Loading branch information
jbardin committed Jan 10, 2020
1 parent b6a041a commit a6cdfad
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion terraform/node_resource_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,34 @@ type NodeDestroyResource struct {
}

var (
_ GraphNodeEvalable = (*NodeDestroyResource)(nil)
_ GraphNodeResource = (*NodeDestroyResource)(nil)
_ GraphNodeReferenceable = (*NodeDestroyResource)(nil)
_ GraphNodeReferencer = (*NodeDestroyResource)(nil)
_ GraphNodeEvalable = (*NodeDestroyResource)(nil)
)

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

// GraphNodeReferenceable, overriding NodeAbstractResource
func (n *NodeDestroyResource) ReferenceableAddrs() []addrs.Referenceable {
// NodeDestroyResource doesn't participate in references: the graph
// builder that created it should ensure directly that it already depends
// on every other node related to its resource, without relying on
// references.
return nil
}

// GraphNodeReferencer, overriding NodeAbstractResource
func (n *NodeDestroyResource) References() []*addrs.Reference {
// NodeDestroyResource doesn't participate in references: the graph
// builder that created it should ensure directly that it already depends
// on every other node related to its resource, without relying on
// references.
return nil
}

// GraphNodeEvalable
func (n *NodeDestroyResource) EvalTree() EvalNode {
// This EvalNode will produce an error if the resource isn't already
Expand All @@ -298,3 +319,13 @@ func (n *NodeDestroyResource) EvalTree() EvalNode {
Addr: n.NodeAbstractResource.ResourceAddr().Resource,
}
}

// GraphNodeResource
func (n *NodeDestroyResource) ResourceAddr() addrs.AbsResource {
return n.NodeAbstractResource.ResourceAddr()
}

// GraphNodeSubpath
func (n *NodeDestroyResource) Path() addrs.ModuleInstance {
return n.NodeAbstractResource.Path()
}

0 comments on commit a6cdfad

Please sign in to comment.