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
|
// Destruction ordering
|
||||||
&DestroyEdgeTransformer{Module: b.Module, State: b.State},
|
&DestroyEdgeTransformer{Module: b.Module, State: b.State},
|
||||||
|
&CBDEdgeTransformer{Module: b.Module, State: b.State},
|
||||||
|
|
||||||
// Create all the providers
|
// Create all the providers
|
||||||
&MissingProviderTransformer{Providers: b.Providers, Factory: providerFactory},
|
&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 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}
|
return []string{n.ResourceState.Provider}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,28 +6,11 @@ import (
|
||||||
|
|
||||||
// NodeDestroyResource represents a resource that is to be destroyed.
|
// NodeDestroyResource represents a resource that is to be destroyed.
|
||||||
type NodeDestroyResource struct {
|
type NodeDestroyResource struct {
|
||||||
Addr *ResourceAddress // Addr is the address for this resource
|
*NodeAbstractResource
|
||||||
ResourceState *ResourceState // State is the resource state for this resource
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodeDestroyResource) Name() string {
|
func (n *NodeDestroyResource) Name() string {
|
||||||
return n.Addr.String() + " (destroy)"
|
return n.NodeAbstractResource.Name() + " (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, "")}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeDestroyer
|
// GraphNodeDestroyer
|
||||||
|
@ -35,14 +18,14 @@ func (n *NodeDestroyResource) DestroyAddr() *ResourceAddress {
|
||||||
return n.Addr
|
return n.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeAttachResourceState
|
// GraphNodeDestroyerCBD
|
||||||
func (n *NodeDestroyResource) ResourceAddr() *ResourceAddress {
|
func (n *NodeDestroyResource) CreateBeforeDestroy() bool {
|
||||||
return n.Addr
|
// If we have no config, we just assume no
|
||||||
}
|
if n.Config == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// GraphNodeAttachResourceState
|
return n.Config.Lifecycle.CreateBeforeDestroy
|
||||||
func (n *NodeDestroyResource) AttachResourceState(s *ResourceState) {
|
|
||||||
n.ResourceState = s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeEvalable
|
// GraphNodeEvalable
|
||||||
|
|
|
@ -59,7 +59,8 @@ func (t *DiffTransformer) Transform(g *Graph) error {
|
||||||
|
|
||||||
// If we're destroying, add the destroy node
|
// If we're destroying, add the destroy node
|
||||||
if inst.Destroy {
|
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
|
// If we have changes, then add the applyable version
|
||||||
|
|
Loading…
Reference in New Issue