mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 09:48:32 -05:00
Previously the Go toolchain had no explicit support for "tools" and so we used the typical Go community workaround of adding "tools.go" files (two, for some reason) that existed only to trick the Go toolchain into considering the tools as dependencies we could track in go.mod. Go 1.24 introduced explicit support for tracking tools as part of go.mod, and the ability to run those using "go tool" instead of "go run", and so this commit switches us over to using that strategy for everything we were previously managing in tools.go. There are some intentional exceptions here: - The protobuf-compile script can't use "go tool" or "go run" because the tools in question are run only indirectly through protoc. However, we do still use the "tool" directive in go.mod to tell the Go toolchain that we depend on those tools, so that it'll track which versions we are currently using as part of go.mod. - Our golangci-lint Makefile target uses "go run" to run a specific version of golangci-lint. We _intentionally_ don't consider that tool to be a direct dependency of OpenTofu because it has a lot of indirect dependencies that would pollute our go.mod file. Therefore that continues to use "go run" after this commit. - Both of our tools.go files previously referred to github.com/nishanths/exhaustive , but nothing actually appears to be using that tool in the current OpenTofu tree, so it's no longer a dependency after this commit. All of the dependencies we have _only_ for tools are now classified as "indirect" in the go.mod file. This is the default behavior of the Go toolchain and appears to be motivated by making it clearer that these modules do not contribute anything to the runtime behavior of OpenTofu. This also corrected a historical oddity in our go.mod where for some reason the "indirect" dependencies had been split across two different "require" directives; they are now all grouped together in a single directive. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package plans
|
|
|
|
// Mode represents the various mutually-exclusive modes for creating a plan.
|
|
type Mode rune
|
|
|
|
//go:generate go tool 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 "tofu plan",
|
|
// and with the plan created by the "tofu 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
|
|
// "tofu plan".
|
|
RefreshOnlyMode Mode = 'R'
|
|
)
|
|
|
|
// UIName returns a name suitable for describing the mode in the UI.
|
|
func (m Mode) UIName() string {
|
|
switch m {
|
|
case NormalMode:
|
|
return "normal"
|
|
case DestroyMode:
|
|
return "destroy"
|
|
case RefreshOnlyMode:
|
|
return "refresh-only"
|
|
default:
|
|
// Should not get here because the cases above should cover every
|
|
// valid value of this type.
|
|
return "unknown"
|
|
}
|
|
}
|