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