mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
36d0a50427
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.
33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
package terraform
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/hashicorp/terraform/internal/addrs"
|
|
"github.com/hashicorp/terraform/internal/plans"
|
|
)
|
|
|
|
// reducePlan takes a planned resource instance change as might be produced by
|
|
// Plan or PlanDestroy and "simplifies" it to a single atomic action to be
|
|
// performed by a specific graph node.
|
|
//
|
|
// Callers must specify whether they are a destroy node or a regular apply node.
|
|
// If the result is NoOp then the given change requires no action for the
|
|
// specific graph node calling this and so evaluation of the that graph node
|
|
// should exit early and take no action.
|
|
//
|
|
// The returned object may either be identical to the input change or a new
|
|
// change object derived from the input. Because of the former case, the caller
|
|
// must not mutate the object returned in OutChange.
|
|
func reducePlan(addr addrs.ResourceInstance, in *plans.ResourceInstanceChange, destroy bool) *plans.ResourceInstanceChange {
|
|
out := in.Simplify(destroy)
|
|
if out.Action != in.Action {
|
|
if destroy {
|
|
log.Printf("[TRACE] reducePlan: %s change simplified from %s to %s for destroy node", addr, in.Action, out.Action)
|
|
} else {
|
|
log.Printf("[TRACE] reducePlan: %s change simplified from %s to %s for apply node", addr, in.Action, out.Action)
|
|
}
|
|
}
|
|
return out
|
|
}
|