mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
c6a7d080d9
Previously there were only two planning modes: normal mode and destroy mode. In that context it made sense for these to be distinguished only by a boolean flag. We're now getting ready to add our third mode, "refresh only". This establishes the idea that planning can be done in one of a number of mutually-exclusive "modes", which are related to but separate from the various other options that serve as modifiers for the plan operation. This commit only introduces the new plans.Mode type and replaces the existing "destroy" flag with a variable of that type. This doesn't cause any change in effective behavior because Terraform Core still supports only NormalMode and DestroyMode, with NewContext rejecting an attempt to create a RefreshMode context for now. It is in retrospect a little odd that the "destroy" flag was part of ContextOpts rather than just an argument to the Plan method, but refactoring that would be too invasive a change for right now so we'll leave this as a field of the context for now and save revisiting that for another day.
32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
package plans
|
|
|
|
// Mode represents the various mutually-exclusive modes for creating a plan.
|
|
type Mode rune
|
|
|
|
//go:generate go run golang.org/x/tools/cmd/stringer -type Mode
|
|
|
|
const (
|
|
// NormalMode is the default planning mode, which aims to synchronize the
|
|
// prior state with remote objects and plan a set of actions intended to
|
|
// make those remote objects better match the current configuration.
|
|
NormalMode Mode = 0
|
|
|
|
// DestroyMode is a special planning mode for situations where the goal
|
|
// is to destroy all remote objects that are bound to instances in the
|
|
// prior state, even if the configuration for those instances is still
|
|
// present.
|
|
//
|
|
// This mode corresponds with the "-destroy" option to "terraform plan",
|
|
// and with the plan created by the "terraform destroy" command.
|
|
DestroyMode Mode = 'D'
|
|
|
|
// RefreshOnlyMode is a special planning mode which only performs the
|
|
// synchronization of prior state with remote objects, and skips any
|
|
// effort to generate any change actions for resource instances even if
|
|
// the configuration has changed relative to the state.
|
|
//
|
|
// This mode corresponds with the "-refresh-only" option to
|
|
// "terraform plan".
|
|
RefreshOnlyMode Mode = 'R'
|
|
)
|