Merge pull request #23822 from hashicorp/jbardin/destroy-resource-deps
NodeDestroyResource needs to be referencable
This commit is contained in:
commit
7500fa7a39
|
@ -277,15 +277,43 @@ func (n *NodeDestroyResourceInstance) EvalTree() EvalNode {
|
|||
// leaving skeleton resource objects in state after their instances have
|
||||
// all been destroyed.
|
||||
type NodeDestroyResource struct {
|
||||
NodeAbstractResource *NodeAbstractResource
|
||||
*NodeAbstractResource
|
||||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeEvalable = (*NodeDestroyResource)(nil)
|
||||
_ GraphNodeResource = (*NodeDestroyResource)(nil)
|
||||
_ GraphNodeReferenceable = (*NodeDestroyResource)(nil)
|
||||
_ GraphNodeReferencer = (*NodeDestroyResource)(nil)
|
||||
_ GraphNodeEvalable = (*NodeDestroyResource)(nil)
|
||||
|
||||
// FIXME: this is here to document that this node is both
|
||||
// GraphNodeProviderConsumer by virtue of the embedded
|
||||
// NodeAbstractResource, but that behavior is not desired and we skip it by
|
||||
// checking for GraphNodeNoProvider.
|
||||
_ GraphNodeProviderConsumer = (*NodeDestroyResource)(nil)
|
||||
_ GraphNodeNoProvider = (*NodeDestroyResource)(nil)
|
||||
)
|
||||
|
||||
func (n *NodeDestroyResource) Name() string {
|
||||
return n.NodeAbstractResource.ResourceAddr().String() + " (clean up state)"
|
||||
return n.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
|
||||
|
@ -295,6 +323,26 @@ func (n *NodeDestroyResource) EvalTree() EvalNode {
|
|||
// leftover husk of a resource in state after all of the child instances
|
||||
// and their objects were destroyed.
|
||||
return &EvalForgetResourceState{
|
||||
Addr: n.NodeAbstractResource.ResourceAddr().Resource,
|
||||
Addr: n.ResourceAddr().Resource,
|
||||
}
|
||||
}
|
||||
|
||||
// GraphNodeResource
|
||||
func (n *NodeDestroyResource) ResourceAddr() addrs.AbsResource {
|
||||
return n.NodeAbstractResource.ResourceAddr()
|
||||
}
|
||||
|
||||
// GraphNodeSubpath
|
||||
func (n *NodeDestroyResource) Path() addrs.ModuleInstance {
|
||||
return n.NodeAbstractResource.Path()
|
||||
}
|
||||
|
||||
// GraphNodeNoProvider
|
||||
// FIXME: this should be removed once the node can be separated from the
|
||||
// Internal NodeAbstractResource behavior.
|
||||
func (n *NodeDestroyResource) NoProvider() {
|
||||
}
|
||||
|
||||
type GraphNodeNoProvider interface {
|
||||
NoProvider()
|
||||
}
|
||||
|
|
|
@ -99,6 +99,13 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
|
|||
needConfigured := map[string]addrs.AbsProviderConfig{}
|
||||
for _, v := range g.Vertices() {
|
||||
|
||||
// FIXME: fix the type that implements this, so it's not a
|
||||
// GraphNodeProviderConsumer.
|
||||
// check if we want to skip connecting this to a provider
|
||||
if _, ok := v.(GraphNodeNoProvider); ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Does the vertex _directly_ use a provider?
|
||||
if pv, ok := v.(GraphNodeProviderConsumer); ok {
|
||||
requested[v] = make(map[string]ProviderRequest)
|
||||
|
@ -275,6 +282,13 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
|
|||
var err error
|
||||
m := providerVertexMap(g)
|
||||
for _, v := range g.Vertices() {
|
||||
// FIXME: fix the type that implements this, so it's not a
|
||||
// GraphNodeProviderConsumer.
|
||||
// check if we want to skip connecting this to a provider
|
||||
if _, ok := v.(GraphNodeNoProvider); ok {
|
||||
continue
|
||||
}
|
||||
|
||||
pv, ok := v.(GraphNodeProviderConsumer)
|
||||
if !ok {
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue