mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
terraform: working on enabling CBD, some cycles
This commit is contained in:
parent
4aa84a2071
commit
aaee4df363
@ -74,6 +74,7 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
||||
|
||||
// Destruction ordering
|
||||
&DestroyEdgeTransformer{Module: b.Module, State: b.State},
|
||||
&CBDEdgeTransformer{Module: b.Module, State: b.State},
|
||||
|
||||
// Create all the providers
|
||||
&MissingProviderTransformer{Providers: b.Providers, Factory: providerFactory},
|
||||
|
@ -81,7 +81,7 @@ func (n *NodeAbstractResource) ProvidedBy() []string {
|
||||
}
|
||||
|
||||
// If we have state, then we will use the provider from there
|
||||
if n.ResourceState != nil {
|
||||
if n.ResourceState != nil && n.ResourceState.Provider != "" {
|
||||
return []string{n.ResourceState.Provider}
|
||||
}
|
||||
|
||||
|
@ -6,28 +6,11 @@ import (
|
||||
|
||||
// NodeDestroyResource represents a resource that is to be destroyed.
|
||||
type NodeDestroyResource struct {
|
||||
Addr *ResourceAddress // Addr is the address for this resource
|
||||
ResourceState *ResourceState // State is the resource state for this resource
|
||||
*NodeAbstractResource
|
||||
}
|
||||
|
||||
func (n *NodeDestroyResource) Name() string {
|
||||
return n.Addr.String() + " (destroy)"
|
||||
}
|
||||
|
||||
// GraphNodeSubPath
|
||||
func (n *NodeDestroyResource) Path() []string {
|
||||
return n.Addr.Path
|
||||
}
|
||||
|
||||
// GraphNodeProviderConsumer
|
||||
func (n *NodeDestroyResource) ProvidedBy() []string {
|
||||
// If we have state, then we will use the provider from there
|
||||
if n.ResourceState != nil && n.ResourceState.Provider != "" {
|
||||
return []string{n.ResourceState.Provider}
|
||||
}
|
||||
|
||||
// Use our type
|
||||
return []string{resourceProvider(n.Addr.Type, "")}
|
||||
return n.NodeAbstractResource.Name() + " (destroy)"
|
||||
}
|
||||
|
||||
// GraphNodeDestroyer
|
||||
@ -35,14 +18,14 @@ func (n *NodeDestroyResource) DestroyAddr() *ResourceAddress {
|
||||
return n.Addr
|
||||
}
|
||||
|
||||
// GraphNodeAttachResourceState
|
||||
func (n *NodeDestroyResource) ResourceAddr() *ResourceAddress {
|
||||
return n.Addr
|
||||
}
|
||||
// GraphNodeDestroyerCBD
|
||||
func (n *NodeDestroyResource) CreateBeforeDestroy() bool {
|
||||
// If we have no config, we just assume no
|
||||
if n.Config == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// GraphNodeAttachResourceState
|
||||
func (n *NodeDestroyResource) AttachResourceState(s *ResourceState) {
|
||||
n.ResourceState = s
|
||||
return n.Config.Lifecycle.CreateBeforeDestroy
|
||||
}
|
||||
|
||||
// GraphNodeEvalable
|
||||
|
@ -59,7 +59,8 @@ func (t *DiffTransformer) Transform(g *Graph) error {
|
||||
|
||||
// If we're destroying, add the destroy node
|
||||
if inst.Destroy {
|
||||
g.Add(&NodeDestroyResource{Addr: addr})
|
||||
abstract := &NodeAbstractResource{Addr: addr}
|
||||
g.Add(&NodeDestroyResource{NodeAbstractResource: abstract})
|
||||
}
|
||||
|
||||
// If we have changes, then add the applyable version
|
||||
|
Loading…
Reference in New Issue
Block a user