terraform: starting work on destroy

This commit is contained in:
Mitchell Hashimoto 2016-09-16 17:29:36 -07:00
parent dfa02e4412
commit 2e8a419fd8
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,51 @@
package terraform
import (
"fmt"
"github.com/hashicorp/terraform/config"
)
// NodeDestroyResource represents a resource that is to be destroyed.
type NodeApplyableResource struct {
Addr *ResourceAddress // Addr is the address for this resource
}
func (n *NodeApplyableResource) Name() string {
return n.Addr.String()
}
// GraphNodeSubPath
func (n *NodeApplyableResource) Path() []string {
return n.Addr.Path
}
// GraphNodeReferenceable
func (n *NodeApplyableResource) ReferenceableName() []string {
if n.Config == nil {
return nil
}
return []string{n.Config.Id()}
}
// GraphNodeProviderConsumer
func (n *NodeApplyableResource) ProvidedBy() []string {
// If we have a config we prefer that above all else
if n.Config != nil {
return []string{resourceProvider(n.Config.Type, n.Config.Provider)}
}
// If we have state, then we will use the provider from there
if n.ResourceState != nil {
return []string{n.ResourceState.Provider}
}
// Use our type
return []string{resourceProvider(n.Addr.Type, "")}
}
// GraphNodeEvalable
func (n *NodeApplyableResource) EvalTree() EvalNode {
return nil
}

View File

@ -40,7 +40,10 @@ func (t *DiffTransformer) Transform(g *Graph) error {
// Go through all the resources in this module.
for name, inst := range m.Resources {
log.Printf("[TRACE] DiffTransformer: Resource %q: %#v", name, inst)
// TODO: Destroy diff
// TODO: destroy
if inst.Destroy {
}
// If this diff has no attribute changes, then we have
// nothing to do and therefore won't add it to the graph.