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