github.com/pulumi/terraform@v1.4.0/pkg/addrs/local_value.go (about) 1 package addrs 2 3 import ( 4 "fmt" 5 ) 6 7 // LocalValue is the address of a local value. 8 type LocalValue struct { 9 referenceable 10 Name string 11 } 12 13 func (v LocalValue) String() string { 14 return "local." + v.Name 15 } 16 17 func (v LocalValue) UniqueKey() UniqueKey { 18 return v // A LocalValue is its own UniqueKey 19 } 20 21 func (v LocalValue) uniqueKeySigil() {} 22 23 // Absolute converts the receiver into an absolute address within the given 24 // module instance. 25 func (v LocalValue) Absolute(m ModuleInstance) AbsLocalValue { 26 return AbsLocalValue{ 27 Module: m, 28 LocalValue: v, 29 } 30 } 31 32 // AbsLocalValue is the absolute address of a local value within a module instance. 33 type AbsLocalValue struct { 34 Module ModuleInstance 35 LocalValue LocalValue 36 } 37 38 // LocalValue returns the absolute address of a local value of the given 39 // name within the receiving module instance. 40 func (m ModuleInstance) LocalValue(name string) AbsLocalValue { 41 return AbsLocalValue{ 42 Module: m, 43 LocalValue: LocalValue{ 44 Name: name, 45 }, 46 } 47 } 48 49 func (v AbsLocalValue) String() string { 50 if len(v.Module) == 0 { 51 return v.LocalValue.String() 52 } 53 return fmt.Sprintf("%s.%s", v.Module.String(), v.LocalValue.String()) 54 }