github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/terraform/graph_config_node_output.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/config" 7 "github.com/hashicorp/terraform/dag" 8 ) 9 10 // GraphNodeConfigOutput represents an output configured within the 11 // configuration. 12 type GraphNodeConfigOutput struct { 13 Output *config.Output 14 } 15 16 func (n *GraphNodeConfigOutput) Name() string { 17 return fmt.Sprintf("output.%s", n.Output.Name) 18 } 19 20 func (n *GraphNodeConfigOutput) ConfigType() GraphNodeConfigType { 21 return GraphNodeConfigTypeOutput 22 } 23 24 func (n *GraphNodeConfigOutput) OutputName() string { 25 return n.Output.Name 26 } 27 28 func (n *GraphNodeConfigOutput) DependableName() []string { 29 return []string{n.Name()} 30 } 31 32 func (n *GraphNodeConfigOutput) DependentOn() []string { 33 vars := n.Output.RawConfig.Variables 34 result := make([]string, 0, len(vars)) 35 for _, v := range vars { 36 if vn := varNameForVar(v); vn != "" { 37 result = append(result, vn) 38 } 39 } 40 41 return result 42 } 43 44 // GraphNodeEvalable impl. 45 func (n *GraphNodeConfigOutput) EvalTree() EvalNode { 46 return &EvalOpFilter{ 47 Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy}, 48 Node: &EvalSequence{ 49 Nodes: []EvalNode{ 50 &EvalWriteOutput{ 51 Name: n.Output.Name, 52 Value: n.Output.RawConfig, 53 }, 54 }, 55 }, 56 } 57 } 58 59 // GraphNodeProxy impl. 60 func (n *GraphNodeConfigOutput) Proxy() bool { 61 return true 62 } 63 64 // GraphNodeDestroyEdgeInclude impl. 65 func (n *GraphNodeConfigOutput) DestroyEdgeInclude(dag.Vertex) bool { 66 return false 67 } 68 69 // GraphNodeFlattenable impl. 70 func (n *GraphNodeConfigOutput) Flatten(p []string) (dag.Vertex, error) { 71 return &GraphNodeConfigOutputFlat{ 72 GraphNodeConfigOutput: n, 73 PathValue: p, 74 }, nil 75 } 76 77 // Same as GraphNodeConfigOutput, but for flattening 78 type GraphNodeConfigOutputFlat struct { 79 *GraphNodeConfigOutput 80 81 PathValue []string 82 } 83 84 func (n *GraphNodeConfigOutputFlat) Name() string { 85 return fmt.Sprintf( 86 "%s.%s", modulePrefixStr(n.PathValue), n.GraphNodeConfigOutput.Name()) 87 } 88 89 func (n *GraphNodeConfigOutputFlat) Path() []string { 90 return n.PathValue 91 } 92 93 func (n *GraphNodeConfigOutputFlat) DependableName() []string { 94 return modulePrefixList( 95 n.GraphNodeConfigOutput.DependableName(), 96 modulePrefixStr(n.PathValue)) 97 } 98 99 func (n *GraphNodeConfigOutputFlat) DependentOn() []string { 100 prefix := modulePrefixStr(n.PathValue) 101 return modulePrefixList( 102 n.GraphNodeConfigOutput.DependentOn(), 103 prefix) 104 }