terraform: working on enabling CBD, some cycles

This commit is contained in:
Mitchell Hashimoto 2016-09-21 18:48:21 -07:00
parent 4aa84a2071
commit aaee4df363
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 13 additions and 28 deletions

View File

@ -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},

View File

@ -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}
} }

View File

@ -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

View File

@ -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