summaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/terraform/terraform/transform_transitive_reduction.go
blob: 21842789cf737dbaa07ab4ceb25f1b2ea2de3d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package terraform

// TransitiveReductionTransformer is a GraphTransformer that performs
// finds the transitive reduction of the graph. For a definition of
// transitive reduction, see Wikipedia.
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 Terraform 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
}