blob: b31e2c765fe2071fb94b1439516718eb468f0674 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package terraform
import (
"github.com/hashicorp/terraform/config/module"
)
// RootVariableTransformer is a GraphTransformer that adds all the root
// variables to the graph.
//
// Root variables are currently no-ops but they must be added to the
// graph since downstream things that depend on them must be able to
// reach them.
type RootVariableTransformer struct {
Module *module.Tree
}
func (t *RootVariableTransformer) Transform(g *Graph) error {
// If no config, no variables
if t.Module == nil {
return nil
}
// If we have no vars, we're done!
vars := t.Module.Config().Variables
if len(vars) == 0 {
return nil
}
// Add all variables here
for _, v := range vars {
node := &NodeRootVariable{
Config: v,
}
// Add it!
g.Add(node)
}
return nil
}
|