terraform: prune orphan outputs in old graph

This makes the old graph also prune orphan outputs in modules.
This will fix shadow graph errors such as #9905 since the old graph will
also behave correctly in these scenarios.

Luckily, because orphan outputs don't rely on anything, we were able to
simply use the same transformer!
This commit is contained in:
Mitchell Hashimoto 2016-11-08 13:21:50 -08:00
parent dfab66e550
commit 9890a2ee91
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 8 additions and 7 deletions

View File

@ -12,7 +12,6 @@ import (
"time"
"github.com/hashicorp/terraform/config/module"
"github.com/hashicorp/terraform/helper/experiment"
)
func TestContext2Apply_basic(t *testing.T) {
@ -2291,10 +2290,6 @@ func TestContext2Apply_outputOrphan(t *testing.T) {
}
func TestContext2Apply_outputOrphanModule(t *testing.T) {
if !experiment.Enabled(experiment.X_newApply) {
t.SkipNow()
}
m := testModule(t, "apply-output-orphan-module")
p := testProvider("aws")
p.ApplyFn = testApplyFn

View File

@ -172,6 +172,9 @@ func (b *BuiltinGraphBuilder) Steps(path []string) []GraphTransformer {
// their dependencies.
&TargetsTransformer{Targets: b.Targets, Destroy: b.Destroy},
// Create orphan output nodes
&OrphanOutputTransformer{Module: b.Root, State: b.State},
// Prune the providers. This must happen only once because flattened
// modules might depend on empty providers.
&PruneProviderTransformer{},

View File

@ -26,7 +26,10 @@ func (n *NodeOutputOrphan) Path() []string {
// GraphNodeEvalable
func (n *NodeOutputOrphan) EvalTree() EvalNode {
return &EvalDeleteOutput{
return &EvalOpFilter{
Ops: []walkOperation{walkRefresh, walkApply, walkDestroy},
Node: &EvalDeleteOutput{
Name: n.OutputName,
},
}
}