github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/addrs/input_variable.go (about) 1 package addrs 2 3 import ( 4 "fmt" 5 ) 6 7 // InputVariable is the address of an input variable. 8 type InputVariable struct { 9 referenceable 10 Name string 11 } 12 13 func (v InputVariable) String() string { 14 return "var." + v.Name 15 } 16 17 // AbsInputVariableInstance is the address of an input variable within a 18 // particular module instance. 19 type AbsInputVariableInstance struct { 20 Module ModuleInstance 21 Variable InputVariable 22 } 23 24 // InputVariable returns the absolute address of the input variable of the 25 // given name inside the receiving module instance. 26 func (m ModuleInstance) InputVariable(name string) AbsInputVariableInstance { 27 return AbsInputVariableInstance{ 28 Module: m, 29 Variable: InputVariable{ 30 Name: name, 31 }, 32 } 33 } 34 35 func (v AbsInputVariableInstance) String() string { 36 if len(v.Module) == 0 { 37 return v.String() 38 } 39 40 return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String()) 41 }