mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
34 lines
735 B
Go
34 lines
735 B
Go
package terraform
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/internal/configs"
|
|
"github.com/hashicorp/terraform/internal/dag"
|
|
)
|
|
|
|
// CountBoundaryTransformer adds a node that depends on everything else
|
|
// so that it runs last in order to clean up the state for nodes that
|
|
// are on the "count boundary": "foo.0" when only one exists becomes "foo"
|
|
type CountBoundaryTransformer struct {
|
|
Config *configs.Config
|
|
}
|
|
|
|
func (t *CountBoundaryTransformer) Transform(g *Graph) error {
|
|
node := &NodeCountBoundary{
|
|
Config: t.Config,
|
|
}
|
|
g.Add(node)
|
|
|
|
// Depends on everything
|
|
for _, v := range g.Vertices() {
|
|
// Don't connect to ourselves
|
|
if v == node {
|
|
continue
|
|
}
|
|
|
|
// Connect!
|
|
g.Connect(dag.BasicEdge(node, v))
|
|
}
|
|
|
|
return nil
|
|
}
|