github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/terraform/transform_local.go (about) 1 package terraform 2 3 import ( 4 "github.com/hashicorp/terraform/config/module" 5 ) 6 7 // LocalTransformer is a GraphTransformer that adds all the local values 8 // from the configuration to the graph. 9 type LocalTransformer struct { 10 Module *module.Tree 11 } 12 13 func (t *LocalTransformer) Transform(g *Graph) error { 14 return t.transformModule(g, t.Module) 15 } 16 17 func (t *LocalTransformer) transformModule(g *Graph, m *module.Tree) error { 18 if m == nil { 19 // Can't have any locals if there's no config 20 return nil 21 } 22 23 for _, local := range m.Config().Locals { 24 node := &NodeLocal{ 25 PathValue: normalizeModulePath(m.Path()), 26 Config: local, 27 } 28 29 g.Add(node) 30 } 31 32 // Also populate locals for child modules 33 for _, c := range m.Children() { 34 if err := t.transformModule(g, c); err != nil { 35 return err 36 } 37 } 38 39 return nil 40 }