]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/terraform/terraform/node_output.go
deps: use go modules for dep mgmt
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / node_output.go
CommitLineData
bae9f6d2
JC
1package terraform
2
3import (
4 "fmt"
5 "strings"
6
7 "github.com/hashicorp/terraform/config"
9b12e4fe 8 "github.com/hashicorp/terraform/dag"
bae9f6d2
JC
9)
10
11// NodeApplyableOutput represents an output that is "applyable":
12// it is ready to be applied.
13type NodeApplyableOutput struct {
14 PathValue []string
15 Config *config.Output // Config is the output in the config
16}
17
18func (n *NodeApplyableOutput) Name() string {
19 result := fmt.Sprintf("output.%s", n.Config.Name)
20 if len(n.PathValue) > 1 {
21 result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result)
22 }
23
24 return result
25}
26
27// GraphNodeSubPath
28func (n *NodeApplyableOutput) Path() []string {
29 return n.PathValue
30}
31
32// RemovableIfNotTargeted
33func (n *NodeApplyableOutput) RemoveIfNotTargeted() bool {
34 // We need to add this so that this node will be removed if
35 // it isn't targeted or a dependency of a target.
36 return true
37}
38
9b12e4fe
JC
39// GraphNodeTargetDownstream
40func (n *NodeApplyableOutput) TargetDownstream(targetedDeps, untargetedDeps *dag.Set) bool {
41 // If any of the direct dependencies of an output are targeted then
42 // the output must always be targeted as well, so its value will always
43 // be up-to-date at the completion of an apply walk.
44 return true
45}
46
bae9f6d2
JC
47// GraphNodeReferenceable
48func (n *NodeApplyableOutput) ReferenceableName() []string {
49 name := fmt.Sprintf("output.%s", n.Config.Name)
50 return []string{name}
51}
52
53// GraphNodeReferencer
54func (n *NodeApplyableOutput) References() []string {
55 var result []string
56 result = append(result, n.Config.DependsOn...)
57 result = append(result, ReferencesFromConfig(n.Config.RawConfig)...)
58 for _, v := range result {
59 split := strings.Split(v, "/")
60 for i, s := range split {
61 split[i] = s + ".destroy"
62 }
63
64 result = append(result, strings.Join(split, "/"))
65 }
66
67 return result
68}
69
70// GraphNodeEvalable
71func (n *NodeApplyableOutput) EvalTree() EvalNode {
72 return &EvalOpFilter{
73 Ops: []walkOperation{walkRefresh, walkPlan, walkApply,
74 walkDestroy, walkInput, walkValidate},
75 Node: &EvalSequence{
76 Nodes: []EvalNode{
77 &EvalWriteOutput{
78 Name: n.Config.Name,
79 Sensitive: n.Config.Sensitive,
80 Value: n.Config.RawConfig,
81 },
82 },
83 },
84 }
85}