Merge pull request #1934 from hashicorp/b-flatten-orphan-outputs

core: flatten orphan outputs
This commit is contained in:
Paul Hinze 2015-05-12 15:14:08 -05:00
commit bb3ed8d740
1 changed files with 30 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package terraform
import (
"fmt"
"github.com/hashicorp/terraform/dag"
)
// GraphNodeOutput is an interface that nodes that are outputs must
@ -66,3 +68,31 @@ func (n *graphNodeOrphanOutput) EvalTree() EvalNode {
},
}
}
// GraphNodeFlattenable impl.
func (n *graphNodeOrphanOutput) Flatten(p []string) (dag.Vertex, error) {
return &graphNodeOrphanOutputFlat{
graphNodeOrphanOutput: n,
PathValue: p,
}, nil
}
type graphNodeOrphanOutputFlat struct {
*graphNodeOrphanOutput
PathValue []string
}
func (n *graphNodeOrphanOutputFlat) Name() string {
return fmt.Sprintf(
"%s.%s", modulePrefixStr(n.PathValue), n.graphNodeOrphanOutput.Name())
}
func (n *graphNodeOrphanOutputFlat) EvalTree() EvalNode {
return &EvalOpFilter{
Ops: []walkOperation{walkApply, walkRefresh},
Node: &EvalDeleteOutput{
Name: n.OutputName,
},
}
}