]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/terraform/addrs/local_value.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / addrs / local_value.go
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 // Absolute converts the receiver into an absolute address within the given
18 // module instance.
19 func (v LocalValue) Absolute(m ModuleInstance) AbsLocalValue {
20 return AbsLocalValue{
21 Module: m,
22 LocalValue: v,
23 }
24 }
25
26 // AbsLocalValue is the absolute address of a local value within a module instance.
27 type AbsLocalValue struct {
28 Module ModuleInstance
29 LocalValue LocalValue
30 }
31
32 // LocalValue returns the absolute address of a local value of the given
33 // name within the receiving module instance.
34 func (m ModuleInstance) LocalValue(name string) AbsLocalValue {
35 return AbsLocalValue{
36 Module: m,
37 LocalValue: LocalValue{
38 Name: name,
39 },
40 }
41 }
42
43 func (v AbsLocalValue) String() string {
44 if len(v.Module) == 0 {
45 return v.LocalValue.String()
46 }
47 return fmt.Sprintf("%s.%s", v.Module.String(), v.LocalValue.String())
48 }