From 9c7fb87ca8c8a54dc1f71705b5c566b5ca8d6ed0 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 12 May 2015 15:10:21 -0500 Subject: [PATCH] core: flatten orphan outputs Hit the "unflattenable node" error again with these. This fixes it. --- terraform/transform_output.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/terraform/transform_output.go b/terraform/transform_output.go index 7741f9d3df..5ea48a0165 100644 --- a/terraform/transform_output.go +++ b/terraform/transform_output.go @@ -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, + }, + } +}