aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/terraform/transform_output.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/terraform/transform_output.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/terraform/transform_output.go46
1 files changed, 41 insertions, 5 deletions
diff --git a/vendor/github.com/hashicorp/terraform/terraform/transform_output.go b/vendor/github.com/hashicorp/terraform/terraform/transform_output.go
index b260f4c..faa25e4 100644
--- a/vendor/github.com/hashicorp/terraform/terraform/transform_output.go
+++ b/vendor/github.com/hashicorp/terraform/terraform/transform_output.go
@@ -1,7 +1,10 @@
1package terraform 1package terraform
2 2
3import ( 3import (
4 "log"
5
4 "github.com/hashicorp/terraform/config/module" 6 "github.com/hashicorp/terraform/config/module"
7 "github.com/hashicorp/terraform/dag"
5) 8)
6 9
7// OutputTransformer is a GraphTransformer that adds all the outputs 10// OutputTransformer is a GraphTransformer that adds all the outputs
@@ -41,11 +44,6 @@ func (t *OutputTransformer) transform(g *Graph, m *module.Tree) error {
41 44
42 // Add all outputs here 45 // Add all outputs here
43 for _, o := range os { 46 for _, o := range os {
44 // Build the node.
45 //
46 // NOTE: For now this is just an "applyable" output. As we build
47 // new graph builders for the other operations I suspect we'll
48 // find a way to parameterize this, require new transforms, etc.
49 node := &NodeApplyableOutput{ 47 node := &NodeApplyableOutput{
50 PathValue: normalizeModulePath(m.Path()), 48 PathValue: normalizeModulePath(m.Path()),
51 Config: o, 49 Config: o,
@@ -57,3 +55,41 @@ func (t *OutputTransformer) transform(g *Graph, m *module.Tree) error {
57 55
58 return nil 56 return nil
59} 57}
58
59// DestroyOutputTransformer is a GraphTransformer that adds nodes to delete
60// outputs during destroy. We need to do this to ensure that no stale outputs
61// are ever left in the state.
62type DestroyOutputTransformer struct {
63}
64
65func (t *DestroyOutputTransformer) Transform(g *Graph) error {
66 for _, v := range g.Vertices() {
67 output, ok := v.(*NodeApplyableOutput)
68 if !ok {
69 continue
70 }
71
72 // create the destroy node for this output
73 node := &NodeDestroyableOutput{
74 PathValue: output.PathValue,
75 Config: output.Config,
76 }
77
78 log.Printf("[TRACE] creating %s", node.Name())
79 g.Add(node)
80
81 deps, err := g.Descendents(v)
82 if err != nil {
83 return err
84 }
85
86 // the destroy node must depend on the eval node
87 deps.Add(v)
88
89 for _, d := range deps.List() {
90 log.Printf("[TRACE] %s depends on %s", node.Name(), dag.VertexName(d))
91 g.Connect(dag.BasicEdge(node, d))
92 }
93 }
94 return nil
95}