mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-16 11:42:58 -06:00
ebcf7455eb
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf". Signed-off-by: Jakub Martin <kubam@spacelift.io> * Gofmt. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Regenerate protobuf. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix comments. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo issue and pull request link changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo comment changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix comment. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo some link changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * make generate && make protobuf Signed-off-by: Jakub Martin <kubam@spacelift.io> --------- Signed-off-by: Jakub Martin <kubam@spacelift.io>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package terraform
|
|
|
|
import (
|
|
"github.com/placeholderplaceholderplaceholder/opentf/internal/addrs"
|
|
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs"
|
|
)
|
|
|
|
// LocalTransformer is a GraphTransformer that adds all the local values
|
|
// from the configuration to the graph.
|
|
type LocalTransformer struct {
|
|
Config *configs.Config
|
|
}
|
|
|
|
func (t *LocalTransformer) Transform(g *Graph) error {
|
|
return t.transformModule(g, t.Config)
|
|
}
|
|
|
|
func (t *LocalTransformer) transformModule(g *Graph, c *configs.Config) error {
|
|
if c == nil {
|
|
// Can't have any locals if there's no config
|
|
return nil
|
|
}
|
|
|
|
for _, local := range c.Module.Locals {
|
|
addr := addrs.LocalValue{Name: local.Name}
|
|
node := &nodeExpandLocal{
|
|
Addr: addr,
|
|
Module: c.Path,
|
|
Config: local,
|
|
}
|
|
g.Add(node)
|
|
}
|
|
|
|
// Also populate locals for child modules
|
|
for _, cc := range c.Children {
|
|
if err := t.transformModule(g, cc); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|