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
&DestroyEdgeTransformer{Module: b.Module, State: b.State},
&CBDEdgeTransformer{Module: b.Module, State: b.State},
// Create all the providers
&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 n.ResourceState != nil {
if n.ResourceState != nil && n.ResourceState.Provider != "" {
return []string{n.ResourceState.Provider}
}

View File

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

View File

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