forked from CiscoDevNet/terraform-provider-mso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_local.go
70 lines (60 loc) · 1.71 KB
/
node_local.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
package terraform
import (
"github.com/hashicorp/terraform-plugin-sdk/internal/addrs"
"github.com/hashicorp/terraform-plugin-sdk/internal/configs"
"github.com/hashicorp/terraform-plugin-sdk/internal/dag"
"github.com/hashicorp/terraform-plugin-sdk/internal/lang"
)
// NodeLocal represents a named local value in a particular module.
//
// Local value nodes only have one operation, common to all walk types:
// evaluate the result and place it in state.
type NodeLocal struct {
Addr addrs.AbsLocalValue
Config *configs.Local
}
var (
_ GraphNodeSubPath = (*NodeLocal)(nil)
_ RemovableIfNotTargeted = (*NodeLocal)(nil)
_ GraphNodeReferenceable = (*NodeLocal)(nil)
_ GraphNodeReferencer = (*NodeLocal)(nil)
_ GraphNodeEvalable = (*NodeLocal)(nil)
_ dag.GraphNodeDotter = (*NodeLocal)(nil)
)
func (n *NodeLocal) Name() string {
return n.Addr.String()
}
// GraphNodeSubPath
func (n *NodeLocal) Path() addrs.ModuleInstance {
return n.Addr.Module
}
// RemovableIfNotTargeted
func (n *NodeLocal) RemoveIfNotTargeted() bool {
return true
}
// GraphNodeReferenceable
func (n *NodeLocal) ReferenceableAddrs() []addrs.Referenceable {
return []addrs.Referenceable{n.Addr.LocalValue}
}
// GraphNodeReferencer
func (n *NodeLocal) References() []*addrs.Reference {
refs, _ := lang.ReferencesInExpr(n.Config.Expr)
return appendResourceDestroyReferences(refs)
}
// GraphNodeEvalable
func (n *NodeLocal) EvalTree() EvalNode {
return &EvalLocal{
Addr: n.Addr.LocalValue,
Expr: n.Config.Expr,
}
}
// dag.GraphNodeDotter impl.
func (n *NodeLocal) DotNode(name string, opts *dag.DotOpts) *dag.DotNode {
return &dag.DotNode{
Name: name,
Attrs: map[string]string{
"label": n.Name(),
"shape": "note",
},
}
}