mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-29 10:21:01 -06:00
c249943360
* WIP: dynamic expand * WIP: add variable and local support * WIP: outputs * WIP: Add referencer * String representation, fixing tests it impacts * Fixes TestContext2Apply_outputOrphanModule * Fix TestContext2Apply_plannedDestroyInterpolatedCount * Update DestroyOutputTransformer and associated types to reflect PlannableOutputs * Remove comment about locals * Remove module count enablement * Removes allowing count for modules, and reverts the test, while adding a Skip()'d test that works when you re-enable the config * update TargetDownstream signature to match master * remove unnecessary method Co-authored-by: James Bardin <j.bardin@gmail.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
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
|
|
}
|
|
|
|
// Absolute converts the receiver into an absolute address within the given
|
|
// module instance.
|
|
func (v InputVariable) Absolute(m ModuleInstance) AbsInputVariableInstance {
|
|
return AbsInputVariableInstance{
|
|
Module: m,
|
|
Variable: v,
|
|
}
|
|
}
|
|
|
|
// 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.Variable.String()
|
|
}
|
|
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String())
|
|
}
|