diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/terraform/addrs/module_call.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/addrs/module_call.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/addrs/module_call.go | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/addrs/module_call.go b/vendor/github.com/hashicorp/terraform/addrs/module_call.go new file mode 100644 index 0000000..09596cc --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/addrs/module_call.go | |||
@@ -0,0 +1,81 @@ | |||
1 | package addrs | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | ) | ||
6 | |||
7 | // ModuleCall is the address of a call from the current module to a child | ||
8 | // module. | ||
9 | // | ||
10 | // There is no "Abs" version of ModuleCall because an absolute module path | ||
11 | // is represented by ModuleInstance. | ||
12 | type ModuleCall struct { | ||
13 | referenceable | ||
14 | Name string | ||
15 | } | ||
16 | |||
17 | func (c ModuleCall) String() string { | ||
18 | return "module." + c.Name | ||
19 | } | ||
20 | |||
21 | // Instance returns the address of an instance of the receiver identified by | ||
22 | // the given key. | ||
23 | func (c ModuleCall) Instance(key InstanceKey) ModuleCallInstance { | ||
24 | return ModuleCallInstance{ | ||
25 | Call: c, | ||
26 | Key: key, | ||
27 | } | ||
28 | } | ||
29 | |||
30 | // ModuleCallInstance is the address of one instance of a module created from | ||
31 | // a module call, which might create multiple instances using "count" or | ||
32 | // "for_each" arguments. | ||
33 | type ModuleCallInstance struct { | ||
34 | referenceable | ||
35 | Call ModuleCall | ||
36 | Key InstanceKey | ||
37 | } | ||
38 | |||
39 | func (c ModuleCallInstance) String() string { | ||
40 | if c.Key == NoKey { | ||
41 | return c.Call.String() | ||
42 | } | ||
43 | return fmt.Sprintf("module.%s%s", c.Call.Name, c.Key) | ||
44 | } | ||
45 | |||
46 | // ModuleInstance returns the address of the module instance that corresponds | ||
47 | // to the receiving call instance when resolved in the given calling module. | ||
48 | // In other words, it returns the child module instance that the receving | ||
49 | // call instance creates. | ||
50 | func (c ModuleCallInstance) ModuleInstance(caller ModuleInstance) ModuleInstance { | ||
51 | return caller.Child(c.Call.Name, c.Key) | ||
52 | } | ||
53 | |||
54 | // Output returns the address of an output of the receiver identified by its | ||
55 | // name. | ||
56 | func (c ModuleCallInstance) Output(name string) ModuleCallOutput { | ||
57 | return ModuleCallOutput{ | ||
58 | Call: c, | ||
59 | Name: name, | ||
60 | } | ||
61 | } | ||
62 | |||
63 | // ModuleCallOutput is the address of a particular named output produced by | ||
64 | // an instance of a module call. | ||
65 | type ModuleCallOutput struct { | ||
66 | referenceable | ||
67 | Call ModuleCallInstance | ||
68 | Name string | ||
69 | } | ||
70 | |||
71 | func (co ModuleCallOutput) String() string { | ||
72 | return fmt.Sprintf("%s.%s", co.Call.String(), co.Name) | ||
73 | } | ||
74 | |||
75 | // AbsOutputValue returns the absolute output value address that corresponds | ||
76 | // to the receving module call output address, once resolved in the given | ||
77 | // calling module. | ||
78 | func (co ModuleCallOutput) AbsOutputValue(caller ModuleInstance) AbsOutputValue { | ||
79 | moduleAddr := co.Call.ModuleInstance(caller) | ||
80 | return moduleAddr.OutputValue(co.Name) | ||
81 | } | ||