mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
02b25e7057
This "kitchen sink" commit is mainly focused on supporting "targets" as a new sub-category of addresses, for use-case like the -target CLI option, but also includes some other functionality to get closer to replacing terraform.ResourceAddress and fill out some missing parts for representing various other address types that are currently represented as strings in the "terraform" package.
42 lines
887 B
Go
42 lines
887 B
Go
package addrs
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// InputVariable is the address of an input variable.
|
|
type InputVariable struct {
|
|
referenceable
|
|
Name string
|
|
}
|
|
|
|
func (v InputVariable) String() string {
|
|
return "var." + v.Name
|
|
}
|
|
|
|
// AbsInputVariableInstance is the address of an input variable within a
|
|
// particular module instance.
|
|
type AbsInputVariableInstance struct {
|
|
Module ModuleInstance
|
|
Variable InputVariable
|
|
}
|
|
|
|
// InputVariable returns the absolute address of the input variable of the
|
|
// given name inside the receiving module instance.
|
|
func (m ModuleInstance) InputVariable(name string) AbsInputVariableInstance {
|
|
return AbsInputVariableInstance{
|
|
Module: m,
|
|
Variable: InputVariable{
|
|
Name: name,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (v AbsInputVariableInstance) String() string {
|
|
if len(v.Module) == 0 {
|
|
return v.String()
|
|
}
|
|
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String())
|
|
}
|