terraform: don't set destroy module on diff

This is something that should be determined and done during an apply. It
doesn't make a lot of sense that the plan is doing it (in its current
form at least).
This commit is contained in:
Mitchell Hashimoto 2016-10-20 21:36:43 -07:00
parent ab4ebcc5c7
commit ceb613d449
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
6 changed files with 6 additions and 54 deletions

2
go.sh
View File

@ -1 +1 @@
go test ./terraform -Xnew-destroy | grep -E '(FAIL|panic)' | tee /dev/tty | wc -l
go test ./terraform -Xnew-apply -Xnew-destroy | grep -E '(FAIL|panic)' | tee /dev/tty | wc -l

View File

@ -438,11 +438,6 @@ func (c *Context) Apply() (*State, error) {
log.Printf("[WARN] terraform: real graph is experiment, shadow is experiment")
real = shadow
} else {
// TODO: remove before branch is done, we're just not ready for this yet
if c.destroy {
shadow = nil
}
log.Printf("[WARN] terraform: real graph is original, shadow is experiment")
}
@ -452,6 +447,11 @@ 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

@ -238,10 +238,6 @@ func (d *ModuleDiff) IsRoot() bool {
func (d *ModuleDiff) String() string {
var buf bytes.Buffer
if d.Destroy {
buf.WriteString("DESTROY MODULE\n")
}
names := make([]string, 0, len(d.Resources))
for name, _ := range d.Resources {
names = append(names, name)

View File

@ -50,9 +50,6 @@ func (b *DestroyPlanGraphBuilder) Steps() []GraphTransformer {
// Attach the configuration to any resources
&AttachResourceConfigTransformer{Module: b.Module},
// Module destroy nodes
&ModuleDestroyTransformer{State: b.State},
// Single root
&RootTransformer{},
}

View File

@ -1139,7 +1139,6 @@ DIFF:
DESTROY: aws_instance.foo
module.child:
DESTROY MODULE
DESTROY: aws_instance.foo
STATE:
@ -1156,10 +1155,8 @@ const testTerraformPlanModuleDestroyCycleStr = `
DIFF:
module.a_module:
DESTROY MODULE
DESTROY: aws_instance.a
module.b_module:
DESTROY MODULE
DESTROY: aws_instance.b
STATE:
@ -1176,7 +1173,6 @@ const testTerraformPlanModuleDestroyMultivarStr = `
DIFF:
module.child:
DESTROY MODULE
DESTROY: aws_instance.foo.0
DESTROY: aws_instance.foo.1

View File

@ -1,37 +0,0 @@
package terraform
// ModuleDestroyTransformer is a GraphTransformer that adds a node
// to the graph that will add a module destroy node for all modules in
// the state.
//
// NOTE: This is _completely unnecessary_ in the new graph worlds. This is
// only done to make old tests pass. However, this node does nothing in
// the new apply graph.
type ModuleDestroyTransformer struct {
State *State
}
func (t *ModuleDestroyTransformer) Transform(g *Graph) error {
// If empty do nothing
if t.State.Empty() {
return nil
}
for _, ms := range t.State.Modules {
// Just a silly edge case that is required to get old tests to pass.
// It is probably a bug with the old graph but we mimic it here
// so that old tests pass.
if len(ms.Path) <= 1 {
continue
}
// Create the node
n := &NodeDestroyableModuleVariable{PathValue: ms.Path}
// Add it to the graph. We don't need any edges because
// it can happen whenever.
g.Add(n)
}
return nil
}