github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/terraform/node_local.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/hashicorp/terraform/config" 8 ) 9 10 // NodeLocal represents a named local value in a particular module. 11 // 12 // Local value nodes only have one operation, common to all walk types: 13 // evaluate the result and place it in state. 14 type NodeLocal struct { 15 PathValue []string 16 Config *config.Local 17 } 18 19 func (n *NodeLocal) Name() string { 20 result := fmt.Sprintf("local.%s", n.Config.Name) 21 if len(n.PathValue) > 1 { 22 result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result) 23 } 24 25 return result 26 } 27 28 // GraphNodeSubPath 29 func (n *NodeLocal) Path() []string { 30 return n.PathValue 31 } 32 33 // RemovableIfNotTargeted 34 func (n *NodeLocal) RemoveIfNotTargeted() bool { 35 return true 36 } 37 38 // GraphNodeReferenceable 39 func (n *NodeLocal) ReferenceableName() []string { 40 name := fmt.Sprintf("local.%s", n.Config.Name) 41 return []string{name} 42 } 43 44 // GraphNodeReferencer 45 func (n *NodeLocal) References() []string { 46 var result []string 47 result = append(result, ReferencesFromConfig(n.Config.RawConfig)...) 48 for _, v := range result { 49 split := strings.Split(v, "/") 50 for i, s := range split { 51 split[i] = s + ".destroy" 52 } 53 54 result = append(result, strings.Join(split, "/")) 55 } 56 57 return result 58 } 59 60 // GraphNodeEvalable 61 func (n *NodeLocal) EvalTree() EvalNode { 62 return &EvalLocal{ 63 Name: n.Config.Name, 64 Value: n.Config.RawConfig, 65 } 66 }