github.com/ricardclau/terraform@v0.6.17-0.20160519222547-283e3ae6b5a9/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 Sensitive: n.Output.Sensitive, 53 Value: n.Output.RawConfig, 54 }, 55 }, 56 }, 57 } 58 } 59 60 // GraphNodeProxy impl. 61 func (n *GraphNodeConfigOutput) Proxy() bool { 62 return true 63 } 64 65 // GraphNodeDestroyEdgeInclude impl. 66 func (n *GraphNodeConfigOutput) DestroyEdgeInclude(dag.Vertex) bool { 67 return false 68 } 69 70 // GraphNodeFlattenable impl. 71 func (n *GraphNodeConfigOutput) Flatten(p []string) (dag.Vertex, error) { 72 return &GraphNodeConfigOutputFlat{ 73 GraphNodeConfigOutput: n, 74 PathValue: p, 75 }, nil 76 } 77 78 // Same as GraphNodeConfigOutput, but for flattening 79 type GraphNodeConfigOutputFlat struct { 80 *GraphNodeConfigOutput 81 82 PathValue []string 83 } 84 85 func (n *GraphNodeConfigOutputFlat) Name() string { 86 return fmt.Sprintf( 87 "%s.%s", modulePrefixStr(n.PathValue), n.GraphNodeConfigOutput.Name()) 88 } 89 90 func (n *GraphNodeConfigOutputFlat) Path() []string { 91 return n.PathValue 92 } 93 94 func (n *GraphNodeConfigOutputFlat) DependableName() []string { 95 return modulePrefixList( 96 n.GraphNodeConfigOutput.DependableName(), 97 modulePrefixStr(n.PathValue)) 98 } 99 100 func (n *GraphNodeConfigOutputFlat) DependentOn() []string { 101 prefix := modulePrefixStr(n.PathValue) 102 return modulePrefixList( 103 n.GraphNodeConfigOutput.DependentOn(), 104 prefix) 105 }