terraform: enable shadow graph and destroy resource mode with addr

This enables the shadow graph since all tests pass!

We also change the destroy node to check the resource type using the
addr since that is always available and reliable. The configuration can
be nil for orphans.
This commit is contained in:
Mitchell Hashimoto 2016-10-20 23:12:07 -07:00
parent a4aea3e085
commit 1523504645
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
5 changed files with 11 additions and 10 deletions

View File

@ -447,11 +447,6 @@ func (c *Context) Apply() (*State, error) {
shadow = real
}
// TODO: remove before branch is done, we're just not ready for this yet
if c.destroy {
shadow = nil
}
// Determine the operation
operation := walkApply
if c.destroy {

View File

@ -739,7 +739,7 @@ func getContextForApply_destroyCrossProviders(
},
},
&ModuleState{
Path: []string{"root", "example"},
Path: []string{"root", "child"},
Resources: map[string]*ResourceState{
"aws_vpc.bar": &ResourceState{
Type: "aws_vpc",

View File

@ -8,7 +8,7 @@ import (
// NodeDestroyResource represents a resource that is to be destroyed.
type NodeDestroyResource struct {
NodeAbstractResource
*NodeAbstractResource
}
func (n *NodeDestroyResource) Name() string {
@ -149,7 +149,11 @@ func (n *NodeDestroyResource) EvalTree() EvalNode {
// Make sure we handle data sources properly.
&EvalIf{
If: func(ctx EvalContext) (bool, error) {
if n.Config.Mode == config.DataResourceMode {
if n.Addr == nil {
return false, fmt.Errorf("nil address")
}
if n.Addr.Mode == config.DataResourceMode {
return true, nil
}

View File

@ -41,7 +41,9 @@ func (t *AttachResourceConfigTransformer) Transform(g *Graph) error {
// Determine what we're looking for
addr := arn.ResourceAddr()
log.Printf("[TRACE] AttachResourceConfigTransformer: Attach resource request: %s", addr)
log.Printf(
"[TRACE] AttachResourceConfigTransformer: Attach resource "+
"config request: %s", addr)
// Get the configuration.
path := normalizeModulePath(addr.Path)

View File

@ -59,7 +59,7 @@ func (t *DiffTransformer) Transform(g *Graph) error {
// If we're destroying, add the destroy node
if inst.Destroy {
abstract := NodeAbstractResource{Addr: addr}
abstract := &NodeAbstractResource{Addr: addr}
g.Add(&NodeDestroyResource{NodeAbstractResource: abstract})
}