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