mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
b9a93a0fe7
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package addrs
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// LocalValue is the address of a local value.
|
|
type LocalValue struct {
|
|
referenceable
|
|
Name string
|
|
}
|
|
|
|
func (v LocalValue) String() string {
|
|
return "local." + v.Name
|
|
}
|
|
|
|
// Absolute converts the receiver into an absolute address within the given
|
|
// module instance.
|
|
func (v LocalValue) Absolute(m ModuleInstance) AbsLocalValue {
|
|
return AbsLocalValue{
|
|
Module: m,
|
|
LocalValue: v,
|
|
}
|
|
}
|
|
|
|
// AbsLocalValue is the absolute address of a local value within a module instance.
|
|
type AbsLocalValue struct {
|
|
Module ModuleInstance
|
|
LocalValue LocalValue
|
|
}
|
|
|
|
// LocalValue returns the absolute address of a local value of the given
|
|
// name within the receiving module instance.
|
|
func (m ModuleInstance) LocalValue(name string) AbsLocalValue {
|
|
return AbsLocalValue{
|
|
Module: m,
|
|
LocalValue: LocalValue{
|
|
Name: name,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (v AbsLocalValue) String() string {
|
|
if len(v.Module) == 0 {
|
|
return v.LocalValue.String()
|
|
}
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.LocalValue.String())
|
|
}
|