]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/terraform/terraform/transform_variable.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / transform_variable.go
CommitLineData
bae9f6d2
JC
1package terraform
2
3import (
107c1cdb
ND
4 "github.com/hashicorp/terraform/addrs"
5 "github.com/hashicorp/terraform/configs"
bae9f6d2
JC
6)
7
8// RootVariableTransformer is a GraphTransformer that adds all the root
9// variables to the graph.
10//
11// Root variables are currently no-ops but they must be added to the
12// graph since downstream things that depend on them must be able to
13// reach them.
14type RootVariableTransformer struct {
107c1cdb 15 Config *configs.Config
bae9f6d2
JC
16}
17
18func (t *RootVariableTransformer) Transform(g *Graph) error {
107c1cdb
ND
19 // We can have no variables if we have no config.
20 if t.Config == nil {
bae9f6d2
JC
21 return nil
22 }
23
107c1cdb
ND
24 // We're only considering root module variables here, since child
25 // module variables are handled by ModuleVariableTransformer.
26 vars := t.Config.Module.Variables
bae9f6d2
JC
27
28 // Add all variables here
29 for _, v := range vars {
30 node := &NodeRootVariable{
107c1cdb
ND
31 Addr: addrs.InputVariable{
32 Name: v.Name,
33 },
bae9f6d2
JC
34 Config: v,
35 }
bae9f6d2
JC
36 g.Add(node)
37 }
38
39 return nil
40}