github.com/opentofu/opentofu@v1.7.1/internal/tofu/transform_transitive_reduction.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package tofu 7 8 // TransitiveReductionTransformer is a GraphTransformer that 9 // finds the transitive reduction of the graph. For a definition of 10 // transitive reduction, see [Wikipedia](https://en.wikipedia.org/wiki/Transitive_reduction). 11 type TransitiveReductionTransformer struct{} 12 13 func (t *TransitiveReductionTransformer) Transform(g *Graph) error { 14 // If the graph isn't valid, skip the transitive reduction. 15 // We don't error here because OpenTofu itself handles graph 16 // validation in a better way, or we assume it does. 17 if err := g.Validate(); err != nil { 18 return nil 19 } 20 21 // Do it 22 g.TransitiveReduction() 23 24 return nil 25 }