opentofu/internal/tofu/transform_transitive_reduction.go
Dmitry Kisler a127607a85
Rename terraform to tofu in GoString method and docstrings (#576)
Signed-off-by: Dmitry Kisler <admin@dkisler.com>
2023-09-26 19:09:27 +02:00

24 lines
704 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tofu
// TransitiveReductionTransformer is a GraphTransformer that
// finds the transitive reduction of the graph. For a definition of
// transitive reduction, see [Wikipedia](https://en.wikipedia.org/wiki/Transitive_reduction).
type TransitiveReductionTransformer struct{}
func (t *TransitiveReductionTransformer) Transform(g *Graph) error {
// If the graph isn't valid, skip the transitive reduction.
// We don't error here because OpenTofu itself handles graph
// validation in a better way, or we assume it does.
if err := g.Validate(); err != nil {
return nil
}
// Do it
g.TransitiveReduction()
return nil
}