mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-23 07:33:32 -06:00
Rename terraform to tofu in GoString
method and docstrings (#576)
Signed-off-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
parent
a7ab3cd5ac
commit
a127607a85
@ -112,7 +112,7 @@ func initCommands(
|
||||
AllowExperimentalFeatures: ExperimentsAllowed(),
|
||||
}
|
||||
|
||||
// The command list is included in the terraform -help
|
||||
// The command list is included in the tofu -help
|
||||
// output, which is in turn included in the docs at
|
||||
// website/docs/cli/commands/index.html.markdown; if you
|
||||
// add, remove or reclassify commands then consider updating
|
||||
|
@ -121,16 +121,16 @@ func TestLocal_planNoConfig(t *testing.T) {
|
||||
func TestLocal_plan_context_error(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
|
||||
// This is an intentionally-invalid value to make terraform.NewContext fail
|
||||
// This is an intentionally-invalid value to make tofu.NewContext fail
|
||||
// when b.Operation calls it.
|
||||
// NOTE: This test was originally using a provider initialization failure
|
||||
// as its forced error condition, but terraform.NewContext is no longer
|
||||
// as its forced error condition, but tofu.NewContext is no longer
|
||||
// responsible for checking that. Invalid parallelism is the last situation
|
||||
// where terraform.NewContext can return error diagnostics, and arguably
|
||||
// where tofu.NewContext can return error diagnostics, and arguably
|
||||
// we should be validating this argument at the UI layer anyway, so perhaps
|
||||
// in future we'll make terraform.NewContext never return errors and then
|
||||
// in future we'll make tofu.NewContext never return errors and then
|
||||
// this test will become redundant, because its purpose is specifically
|
||||
// to test that we properly unlock the state if terraform.NewContext
|
||||
// to test that we properly unlock the state if tofu.NewContext
|
||||
// returns an error.
|
||||
if b.ContextOpts == nil {
|
||||
b.ContextOpts = &tofu.ContextOpts{}
|
||||
|
@ -44,7 +44,7 @@ var (
|
||||
})
|
||||
)
|
||||
|
||||
// mockInput is a mock implementation of terraform.UIInput.
|
||||
// mockInput is a mock implementation of tofu.UIInput.
|
||||
type mockInput struct {
|
||||
answers map[string]string
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
// Provider is an implementation of providers.Interface
|
||||
type Provider struct{}
|
||||
|
||||
// NewProvider returns a new terraform provider
|
||||
// NewProvider returns a new tofu provider
|
||||
func NewProvider() providers.Interface {
|
||||
return &Provider{}
|
||||
}
|
||||
@ -32,7 +32,7 @@ func (p *Provider) GetProviderSchema() providers.GetProviderSchemaResponse {
|
||||
|
||||
// ValidateProviderConfig is used to validate the configuration values.
|
||||
func (p *Provider) ValidateProviderConfig(req providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse {
|
||||
// At this moment there is nothing to configure for the terraform provider,
|
||||
// At this moment there is nothing to configure for the tofu provider,
|
||||
// so we will happily return without taking any action
|
||||
var res providers.ValidateProviderConfigResponse
|
||||
res.PreparedConfig = req.Config
|
||||
@ -43,7 +43,7 @@ func (p *Provider) ValidateProviderConfig(req providers.ValidateProviderConfigRe
|
||||
func (p *Provider) ValidateDataResourceConfig(req providers.ValidateDataResourceConfigRequest) providers.ValidateDataResourceConfigResponse {
|
||||
// FIXME: move the backend configuration validate call that's currently
|
||||
// inside the read method into here so that we can catch provider configuration
|
||||
// errors in terraform validate as well as during terraform plan.
|
||||
// errors in tofu validate as well as during tofu plan.
|
||||
var res providers.ValidateDataResourceConfigResponse
|
||||
|
||||
// This should not happen
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
// Package checks contains the models for representing various kinds of
|
||||
// declarative condition checks that can be defined in a Terraform module
|
||||
// and then evaluated and reported by Terraform Core during plan and apply
|
||||
// and then evaluated and reported by OpenTofu Core during plan and apply
|
||||
// operations.
|
||||
package checks
|
||||
|
@ -43,7 +43,7 @@ type State struct {
|
||||
// the evaluation status for a particular addrs.ConfigCheckable address.
|
||||
//
|
||||
// Its initial state, at the beginning of a run, is that it doesn't even know
|
||||
// how many checkable objects will be dynamically-declared yet. Terraform Core
|
||||
// how many checkable objects will be dynamically-declared yet. OpenTofu Core
|
||||
// will notify the State object of the associated Checkables once
|
||||
// it has decided the appropriate expansion of that configuration object,
|
||||
// and then will gradually report the results of each check once the graph
|
||||
@ -61,11 +61,11 @@ type configCheckableState struct {
|
||||
// objects represents the set of dynamic checkable objects associated
|
||||
// with this configuration construct. This is initially nil to represent
|
||||
// that we don't know the objects yet, and is replaced by a non-nil map
|
||||
// once Terraform Core reports the expansion of this configuration
|
||||
// once OpenTofu Core reports the expansion of this configuration
|
||||
// construct.
|
||||
//
|
||||
// The leaf Status values will initially be StatusUnknown
|
||||
// and then gradually updated by Terraform Core as it visits the
|
||||
// and then gradually updated by OpenTofu Core as it visits the
|
||||
// individual checkable objects and reports their status.
|
||||
objects addrs.Map[addrs.Checkable, map[addrs.CheckRuleType][]Status]
|
||||
}
|
||||
@ -187,7 +187,7 @@ func (c *State) AggregateCheckStatus(addr addrs.ConfigCheckable) Status {
|
||||
// ObjectCheckStatus returns a summarization of all of the check results
|
||||
// for a particular checkable object into a single status.
|
||||
//
|
||||
// The given address must refer to a checkable object that Terraform Core
|
||||
// The given address must refer to a checkable object that OpenTofu Core
|
||||
// previously reported while doing a graph walk, or this method will panic.
|
||||
func (c *State) ObjectCheckStatus(addr addrs.Checkable) Status {
|
||||
c.mu.Lock()
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/addrs"
|
||||
)
|
||||
|
||||
// These are the "Report"-prefixed methods of Checks used by Terraform Core
|
||||
// These are the "Report"-prefixed methods of Checks used by OpenTofu Core
|
||||
// to gradually signal the results of checks during a plan or apply operation.
|
||||
|
||||
// ReportCheckableObjects is the interface by which Terraform Core should
|
||||
// ReportCheckableObjects is the interface by which OpenTofu Core should
|
||||
// tell the State object which specific checkable objects were declared
|
||||
// by the given configuration object.
|
||||
//
|
||||
@ -33,7 +33,7 @@ func (c *State) ReportCheckableObjects(configAddr addrs.ConfigCheckable, objectA
|
||||
}
|
||||
|
||||
// At this point we pre-populate all of the check results as StatusUnknown,
|
||||
// so that even if we never hear from Terraform Core again we'll still
|
||||
// so that even if we never hear from OpenTofu Core again we'll still
|
||||
// remember that these results were all pending.
|
||||
st.objects = addrs.MakeMap[addrs.Checkable, map[addrs.CheckRuleType][]Status]()
|
||||
for _, objectAddr := range objectAddrs {
|
||||
@ -54,7 +54,7 @@ func (c *State) ReportCheckableObjects(configAddr addrs.ConfigCheckable, objectA
|
||||
}
|
||||
}
|
||||
|
||||
// ReportCheckResult is the interface by which Terraform Core should tell the
|
||||
// ReportCheckResult is the interface by which OpenTofu Core should tell the
|
||||
// State object the result of a specific check for an object that was
|
||||
// previously registered with ReportCheckableObjects.
|
||||
//
|
||||
|
@ -46,7 +46,7 @@ const (
|
||||
)
|
||||
|
||||
// Cloud is an implementation of EnhancedBackend in service of the cloud backend
|
||||
// integration for Terraform CLI. This backend is not intended to be surfaced at the user level and
|
||||
// integration for OpenTofu CLI. This backend is not intended to be surfaced at the user level and
|
||||
// is instead an implementation detail of cloud.Cloud.
|
||||
type Cloud struct {
|
||||
// CLI and Colorize control the CLI output. If CLI is nil then no CLI
|
||||
@ -55,7 +55,7 @@ type Cloud struct {
|
||||
CLIColor *colorstring.Colorize
|
||||
|
||||
// ContextOpts are the base context options to set when initializing a
|
||||
// new Terraform context. Many of these will be overridden or merged by
|
||||
// new OpenTofu context. Many of these will be overridden or merged by
|
||||
// Operation. See Operation for more details.
|
||||
ContextOpts *tofu.ContextOpts
|
||||
|
||||
@ -94,7 +94,7 @@ type Cloud struct {
|
||||
opLock sync.Mutex
|
||||
|
||||
// ignoreVersionConflict, if true, will disable the requirement that the
|
||||
// local Terraform version matches the remote workspace's configured
|
||||
// local OpenTofu version matches the remote workspace's configured
|
||||
// version. This will also cause VerifyWorkspaceTerraformVersion to return
|
||||
// a warning diagnostic instead of an error.
|
||||
ignoreVersionConflict bool
|
||||
@ -362,7 +362,7 @@ func (b *Cloud) Configure(obj cty.Value) tfdiags.Diagnostics {
|
||||
if parseErr != nil || currentAPIVersion.LessThan(desiredAPIVersion) {
|
||||
log.Printf("[TRACE] API version check failed; want: >= %s, got: %s", desiredAPIVersion.Original(), currentAPIVersion)
|
||||
if b.runningInAutomation {
|
||||
// It should never be possible for this Terraform process to be mistakenly
|
||||
// It should never be possible for this OpenTofu process to be mistakenly
|
||||
// used internally within an unsupported Terraform Enterprise install - but
|
||||
// just in case it happens, give an actionable error.
|
||||
diags = diags.Append(
|
||||
@ -699,7 +699,7 @@ func (b *Cloud) StateMgr(name string) (statemgr.Full, error) {
|
||||
|
||||
remoteTFVersion = workspace.TerraformVersion
|
||||
|
||||
// Attempt to set the new workspace to use this version of Terraform. This
|
||||
// Attempt to set the new workspace to use this version of OpenTofu. This
|
||||
// can fail if there's no enabled tool_version whose name matches our
|
||||
// version string, but that's expected sometimes -- just warn and continue.
|
||||
versionOptions := tfe.WorkspaceUpdateOptions{
|
||||
@ -914,8 +914,8 @@ func (b *Cloud) cancel(cancelCtx context.Context, op *backend.Operation, r *tfe.
|
||||
}
|
||||
|
||||
// IgnoreVersionConflict allows commands to disable the fall-back check that
|
||||
// the local Terraform version matches the remote workspace's configured
|
||||
// Terraform version. This should be called by commands where this check is
|
||||
// the local OpenTofu version matches the remote workspace's configured
|
||||
// OpenTofu version. This should be called by commands where this check is
|
||||
// unnecessary, such as those performing remote operations, or read-only
|
||||
// operations. It will also be called if the user uses a command-line flag to
|
||||
// override this check.
|
||||
@ -923,8 +923,8 @@ func (b *Cloud) IgnoreVersionConflict() {
|
||||
b.ignoreVersionConflict = true
|
||||
}
|
||||
|
||||
// VerifyWorkspaceTerraformVersion compares the local Terraform version against
|
||||
// the workspace's configured Terraform version. If they are compatible, this
|
||||
// VerifyWorkspaceTerraformVersion compares the local OpenTofu version against
|
||||
// the workspace's configured OpenTofu version. If they are compatible, this
|
||||
// means that there are no state compatibility concerns, so it returns no
|
||||
// diagnostics.
|
||||
//
|
||||
@ -951,13 +951,13 @@ func (b *Cloud) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.Di
|
||||
}
|
||||
|
||||
// If the workspace has the pseudo-version "latest", all bets are off. We
|
||||
// cannot reasonably determine what the intended Terraform version is, so
|
||||
// cannot reasonably determine what the intended OpenTofu version is, so
|
||||
// we'll skip version verification.
|
||||
if workspace.TerraformVersion == "latest" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the workspace has execution-mode set to local, the remote Terraform
|
||||
// If the workspace has execution-mode set to local, the remote OpenTofu
|
||||
// version is effectively meaningless, so we'll skip version verification.
|
||||
if isLocalExecutionMode(workspace.ExecutionMode) {
|
||||
return nil
|
||||
|
@ -298,7 +298,7 @@ func unusableSavedPlanError(status tfe.RunStatus, url string) error {
|
||||
reason = "The given plan file refers to a plan that had errors and did not complete successfully. It cannot be applied."
|
||||
case tfe.RunPlannedAndFinished:
|
||||
// Note: planned and finished can also indicate a plan-only run, but
|
||||
// terraform plan can't create a saved plan for a plan-only run, so we
|
||||
// tofu plan can't create a saved plan for a plan-only run, so we
|
||||
// know it's no-changes in this case.
|
||||
summary = "Saved plan has no changes"
|
||||
reason = "The given plan file contains no changes, so it cannot be applied."
|
||||
|
@ -116,7 +116,7 @@ func (b *Cloud) plan(stopCtx, cancelCtx context.Context, op *backend.Operation,
|
||||
b.CLI.Output(b.Colorize().Color(strings.TrimSpace(header) + "\n"))
|
||||
}
|
||||
|
||||
// Plan-only means they ran terraform plan without -out.
|
||||
// Plan-only means they ran tofu plan without -out.
|
||||
provisional := op.PlanOutPath != ""
|
||||
planOnly := op.Type == backend.OperationTypePlan && !provisional
|
||||
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
// ShowPlanForRun downloads the JSON plan output for the specified cloud run
|
||||
// (either the redacted or unredacted format, per the caller's request), and
|
||||
// returns it in a cloudplan.RemotePlanJSON wrapper struct (along with various
|
||||
// metadata required by terraform show). It's intended for use by the terraform
|
||||
// metadata required by tofu show). It's intended for use by the tofu
|
||||
// show command, in order to format and display a saved cloud plan.
|
||||
func (b *Cloud) ShowPlanForRun(ctx context.Context, runID, runHostname string, redacted bool) (*cloudplan.RemotePlanJSON, error) {
|
||||
var jsonBytes []byte
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// A brief discourse on the theory of testing for this feature. Doing
|
||||
// `terraform show cloudplan.tfplan` relies on the correctness of the following
|
||||
// `tofu show cloudplan.tfplan` relies on the correctness of the following
|
||||
// behaviors:
|
||||
//
|
||||
// 1. TFC API returns redacted or unredacted plan JSON on request, if permission
|
||||
|
@ -271,7 +271,7 @@ func skipWithoutRemoteTerraformVersion(t *testing.T) {
|
||||
|
||||
findTfVersion:
|
||||
for {
|
||||
// TODO: update go-tfe Read() to retrieve a terraform version by name.
|
||||
// TODO: update go-tfe Read() to retrieve a tofu version by name.
|
||||
// Currently you can only retrieve by ID.
|
||||
tfVersionList, err := tfeClient.Admin.TerraformVersions.List(context.Background(), opts)
|
||||
if err != nil {
|
||||
|
@ -26,8 +26,8 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
|
||||
wsName := "prod"
|
||||
// Creating the workspace here instead of it being created
|
||||
// dynamically in the Cloud StateMgr because we want to ensure that
|
||||
// the terraform version selected for the workspace matches the
|
||||
// terraform version of this current branch.
|
||||
// the tofu version selected for the workspace matches the
|
||||
// tofu version of this current branch.
|
||||
_ = createWorkspace(t, orgName, tfe.WorkspaceCreateOptions{
|
||||
Name: tfe.String("prod"),
|
||||
TerraformVersion: tfe.String(tfversion.String()),
|
||||
@ -167,7 +167,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
|
||||
{
|
||||
prep: func(t *testing.T, orgName, dir string) {
|
||||
tag := "app"
|
||||
// This is only here to ensure that the updated terraform version is
|
||||
// This is only here to ensure that the updated tofu version is
|
||||
// present in the workspace, and it does not default to a lower
|
||||
// version that does not support `cloud`.
|
||||
_ = createWorkspace(t, orgName, tfe.WorkspaceCreateOptions{
|
||||
@ -263,7 +263,7 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
|
||||
prep: func(t *testing.T, orgName, dir string) {
|
||||
name := "service"
|
||||
// Doing this here instead of relying on dynamic workspace creation
|
||||
// because we want to set the terraform version here so that it is
|
||||
// because we want to set the tofu version here so that it is
|
||||
// using the right version for post init operations.
|
||||
_ = createWorkspace(t, orgName, tfe.WorkspaceCreateOptions{
|
||||
Name: tfe.String(name),
|
||||
|
@ -59,7 +59,7 @@ func DetectConfigChangeType(wdState *legacy.BackendState, config *configs.Backen
|
||||
|
||||
// "uninit" here means that the working directory is totally uninitialized,
|
||||
// even taking into account the possibility of implied local state that
|
||||
// therefore doesn't typically require explicit "terraform init".
|
||||
// therefore doesn't typically require explicit "tofu init".
|
||||
wdIsUninit := wdState == nil && !haveLocalStates
|
||||
|
||||
switch {
|
||||
|
@ -597,7 +597,7 @@ func (s *State) readSnapshotIntervalHeader(status int, header http.Header) {
|
||||
}
|
||||
|
||||
// tfeOutputToCtyValue decodes a combination of TFE output value and detailed-type to create a
|
||||
// cty value that is suitable for use in terraform.
|
||||
// cty value that is suitable for use in tofu.
|
||||
func tfeOutputToCtyValue(output tfe.StateVersionOutput) (cty.Value, error) {
|
||||
var result cty.Value
|
||||
bufType, err := json.Marshal(output.DetailedType)
|
||||
|
@ -58,7 +58,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// mockInput is a mock implementation of terraform.UIInput.
|
||||
// mockInput is a mock implementation of tofu.UIInput.
|
||||
type mockInput struct {
|
||||
answers map[string]string
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ const PluginPathFile = "plugin_path"
|
||||
const pluginMachineName = runtime.GOOS + "_" + runtime.GOARCH
|
||||
|
||||
// DefaultPluginVendorDir is the location in the config directory to look for
|
||||
// user-added plugin binaries. Terraform only reads from this path if it
|
||||
// exists, it is never created by terraform.
|
||||
// user-added plugin binaries. OpenTofu only reads from this path if it
|
||||
// exists, it is never created by tofu.
|
||||
const DefaultPluginVendorDir = "terraform.d/plugins/" + pluginMachineName
|
||||
|
||||
// DefaultStateFilename is the default filename used for the state file.
|
||||
|
@ -734,7 +734,7 @@ func testInputMap(t *testing.T, answers map[string]string) func() {
|
||||
//
|
||||
// If such a block isn't present, or if it isn't empty, then an error will
|
||||
// be returned about the backend configuration having changed and that
|
||||
// "terraform init" must be run, since the test backend config cache created
|
||||
// "tofu init" must be run, since the test backend config cache created
|
||||
// by this function contains the hash for an empty configuration.
|
||||
func testBackendState(t *testing.T, s *states.State, c int) (*legacy.State, *httptest.Server) {
|
||||
t.Helper()
|
||||
|
@ -105,9 +105,9 @@ func TestConsole_tfvars(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConsole_unsetRequiredVars(t *testing.T) {
|
||||
// This test is verifying that it's possible to run "terraform console"
|
||||
// This test is verifying that it's possible to run "tofu console"
|
||||
// without providing values for all required variables, without
|
||||
// "terraform console" producing an interactive prompt for those variables
|
||||
// "tofu console" producing an interactive prompt for those variables
|
||||
// or producing errors. Instead, it should allow evaluation in that
|
||||
// partial context but see the unset variables values as being unknown.
|
||||
//
|
||||
|
@ -34,7 +34,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// FmtCommand is a Command implementation that rewrites Terraform config
|
||||
// FmtCommand is a Command implementation that rewrites OpenTofu config
|
||||
// files to a canonical format and style.
|
||||
type FmtCommand struct {
|
||||
Meta
|
||||
@ -256,7 +256,7 @@ func (c *FmtCommand) processDir(path string, stdout io.Writer) tfdiags.Diagnosti
|
||||
}
|
||||
|
||||
// We do not recurse into child directories by default because we
|
||||
// want to mimic the file-reading behavior of "terraform plan", etc,
|
||||
// want to mimic the file-reading behavior of "tofu plan", etc,
|
||||
// operating on one module at a time.
|
||||
continue
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package format contains helpers for formatting various Terraform
|
||||
// Package format contains helpers for formatting various OpenTofu
|
||||
// structures for human-readabout output.
|
||||
//
|
||||
// This package is used by the official Terraform CLI in formatting any
|
||||
// This package is used by the official OpenTofu CLI in formatting any
|
||||
// output and is exported to encourage non-official frontends to mimic the
|
||||
// output formatting as much as possible so that text formats of Terraform
|
||||
// output formatting as much as possible so that text formats of OpenTofu
|
||||
// structures have a consistent look and feel.
|
||||
package format
|
||||
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
// If such an attribute is found, its name and string value intended for
|
||||
// display are returned. Both returned strings are empty if no such attribute
|
||||
// exists, in which case the caller should assume that the resource instance
|
||||
// address within the Terraform configuration is the best available identifier.
|
||||
// address within the OpenTofu configuration is the best available identifier.
|
||||
//
|
||||
// This is only a best-effort sort of thing, relying on naming conventions in
|
||||
// our resource type schemas. The result is not guaranteed to be unique, but
|
||||
|
@ -83,7 +83,7 @@ func TestGet_update(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGet_cancel(t *testing.T) {
|
||||
// This test runs `terraform get` as if SIGINT (or similar on other
|
||||
// This test runs `tofu get` as if SIGINT (or similar on other
|
||||
// platforms) were sent to it, testing that it is interruptible.
|
||||
|
||||
wd := tempWorkingDirFixture(t, "init-registry-module")
|
||||
|
@ -135,7 +135,7 @@ func (c *GraphCommand) Run(args []string) int {
|
||||
case "apply":
|
||||
plan := lr.Plan
|
||||
|
||||
// Historically "terraform graph" would allow the nonsensical request to
|
||||
// Historically "tofu graph" would allow the nonsensical request to
|
||||
// render an apply graph without a plan, so we continue to support that
|
||||
// here, though perhaps one day this should be an error.
|
||||
if lr.Plan == nil {
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
// ImportCommand is a cli.Command implementation that imports resources
|
||||
// into the Terraform state.
|
||||
// into the OpenTofu state.
|
||||
type ImportCommand struct {
|
||||
Meta
|
||||
}
|
||||
@ -112,7 +112,7 @@ func (c *ImportCommand) Run(args []string) int {
|
||||
|
||||
// Verify that the given address points to something that exists in config.
|
||||
// This is to reduce the risk that a typo in the resource address will
|
||||
// import something that Terraform will want to immediately destroy on
|
||||
// import something that OpenTofu will want to immediately destroy on
|
||||
// the next plan, and generally acts as a reassurance of user intent.
|
||||
targetConfig := config.DescendentForInstance(addr.Module)
|
||||
if targetConfig == nil {
|
||||
@ -206,7 +206,7 @@ func (c *ImportCommand) Run(args []string) int {
|
||||
}
|
||||
opReq.View = views.NewOperation(arguments.ViewHuman, c.RunningInAutomation, c.View)
|
||||
|
||||
// Check remote Terraform version is compatible
|
||||
// Check remote OpenTofu version is compatible
|
||||
remoteVersionDiags := c.remoteVersionCheck(b, opReq.Workspace)
|
||||
diags = diags.Append(remoteVersionDiags)
|
||||
c.showDiagnostics(diags)
|
||||
|
@ -249,11 +249,11 @@ func (c *InitCommand) Run(args []string) int {
|
||||
// whole configuration tree.
|
||||
config, confDiags := c.loadConfigWithTests(path, testsDirectory)
|
||||
// configDiags will be handled after the version constraint check, since an
|
||||
// incorrect version of terraform may be producing errors for configuration
|
||||
// incorrect version of tofu may be producing errors for configuration
|
||||
// constructs added in later versions.
|
||||
|
||||
// Before we go further, we'll check to make sure none of the modules in
|
||||
// the configuration declare that they don't support this Terraform
|
||||
// the configuration declare that they don't support this OpenTofu
|
||||
// version, so we can produce a version-related error message rather than
|
||||
// potentially-confusing downstream errors.
|
||||
versionDiags := tofu.CheckCoreVersionRequirements(config)
|
||||
@ -515,9 +515,9 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
|
||||
ctx, span := tracer.Start(ctx, "install providers")
|
||||
defer span.End()
|
||||
|
||||
// Dev overrides cause the result of "terraform init" to be irrelevant for
|
||||
// Dev overrides cause the result of "tofu init" to be irrelevant for
|
||||
// any overridden providers, so we'll warn about it to avoid later
|
||||
// confusion when Terraform ends up using a different provider than the
|
||||
// confusion when OpenTofu ends up using a different provider than the
|
||||
// lock file called for.
|
||||
diags = diags.Append(c.providerDevOverrideInitWarnings())
|
||||
|
||||
@ -560,7 +560,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
|
||||
inst = c.providerInstaller()
|
||||
} else {
|
||||
// If the user passes at least one -plugin-dir then that circumvents
|
||||
// the usual sources and forces Terraform to consult only the given
|
||||
// the usual sources and forces OpenTofu to consult only the given
|
||||
// directories. Anything not available in one of those directories
|
||||
// is not available for installation.
|
||||
source := c.providerCustomLocalDirectorySource(pluginDirs)
|
||||
@ -826,7 +826,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
|
||||
// We're going to use this opportunity to track if we have any
|
||||
// "incomplete" installs of providers. An incomplete install is
|
||||
// when we are only going to write the local hashes into our lock
|
||||
// file which means a `terraform init` command will fail in future
|
||||
// file which means a `tofu init` command will fail in future
|
||||
// when used on machines of a different architecture.
|
||||
//
|
||||
// We want to print a warning about this.
|
||||
@ -948,7 +948,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
|
||||
|
||||
if previousLocks.Empty() {
|
||||
// A change from empty to non-empty is special because it suggests
|
||||
// we're running "terraform init" for the first time against a
|
||||
// we're running "tofu init" for the first time against a
|
||||
// new configuration. In that case we'll take the opportunity to
|
||||
// say a little about what the dependency lock file is, for new
|
||||
// users or those who are upgrading from a previous Terraform
|
||||
@ -1241,7 +1241,7 @@ again to reinitialize your working directory.
|
||||
`
|
||||
|
||||
// providerProtocolTooOld is a message sent to the CLI UI if the provider's
|
||||
// supported protocol versions are too old for the user's version of terraform,
|
||||
// supported protocol versions are too old for the user's version of tofu,
|
||||
// but a newer version of the provider is compatible.
|
||||
const providerProtocolTooOld = `Provider %q v%s is not compatible with OpenTofu %s.
|
||||
Provider version %s is the latest compatible version. Select it with the following version constraint:
|
||||
@ -1254,8 +1254,8 @@ Consult the documentation for this provider for more information on compatibilit
|
||||
`
|
||||
|
||||
// providerProtocolTooNew is a message sent to the CLI UI if the provider's
|
||||
// supported protocol versions are too new for the user's version of terraform,
|
||||
// and the user could either upgrade terraform or choose an older version of the
|
||||
// supported protocol versions are too new for the user's version of tofu,
|
||||
// and the user could either upgrade tofu or choose an older version of the
|
||||
// provider.
|
||||
const providerProtocolTooNew = `Provider %q v%s is not compatible with OpenTofu %s.
|
||||
You need to downgrade to v%s or earlier. Select it with the following constraint:
|
||||
|
@ -334,7 +334,7 @@ func TestInit_backendConfigFile(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// the backend config file must not be a full terraform block
|
||||
// the backend config file must not be a full tofu block
|
||||
t.Run("full-backend-config-file", func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
|
@ -70,7 +70,7 @@ func MarshalCheckStates(results *states.CheckResults) []byte {
|
||||
// checkResultStatic is the container for the static, configuration-driven
|
||||
// idea of "checkable object" -- a resource block with conditions, for example --
|
||||
// which ensures that we can always say _something_ about each checkable
|
||||
// object in the configuration even if Terraform Core encountered an error
|
||||
// object in the configuration even if OpenTofu Core encountered an error
|
||||
// before being able to determine the dynamic instances of the checkable object.
|
||||
type checkResultStatic struct {
|
||||
// Address is the address of the checkable object this result relates to.
|
||||
@ -86,7 +86,7 @@ type checkResultStatic struct {
|
||||
}
|
||||
|
||||
// checkResultDynamic describes the check result for a dynamic object, which
|
||||
// results from Terraform Core evaluating the "expansion" (e.g. count or for_each)
|
||||
// results from OpenTofu Core evaluating the "expansion" (e.g. count or for_each)
|
||||
// of the containing object or its own containing module(s).
|
||||
type checkResultDynamic struct {
|
||||
// Address augments the Address of the containing checkResultStatic with
|
||||
@ -99,7 +99,7 @@ type checkResultDynamic struct {
|
||||
// Problems describes some optional details associated with a failure
|
||||
// status, describing what fails.
|
||||
//
|
||||
// This does not include the errors for status "error", because Terraform
|
||||
// This does not include the errors for status "error", because OpenTofu
|
||||
// Core emits those separately as normal diagnostics. However, if a
|
||||
// particular object has a mixture of conditions that failed and conditions
|
||||
// that were invalid then status can be "error" while simultaneously
|
||||
|
@ -26,7 +26,7 @@ type config struct {
|
||||
|
||||
// ProviderConfig describes all of the provider configurations throughout the
|
||||
// configuration tree, flattened into a single map for convenience since
|
||||
// provider configurations are the one concept in Terraform that can span across
|
||||
// provider configurations are the one concept in OpenTofu that can span across
|
||||
// module boundaries.
|
||||
type providerConfig struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
@ -119,7 +119,7 @@ type provisioner struct {
|
||||
Expressions map[string]interface{} `json:"expressions,omitempty"`
|
||||
}
|
||||
|
||||
// Marshal returns the json encoding of terraform configuration.
|
||||
// Marshal returns the json encoding of tofu configuration.
|
||||
func Marshal(c *configs.Config, schemas *tofu.Schemas) ([]byte, error) {
|
||||
var output config
|
||||
|
||||
@ -333,7 +333,7 @@ func marshalModule(c *configs.Config, schemas *tofu.Schemas, addr string) (modul
|
||||
dependencies := make([]string, len(v.DependsOn))
|
||||
for i, d := range v.DependsOn {
|
||||
ref, diags := addrs.ParseRef(d)
|
||||
// we should not get an error here, because `terraform validate`
|
||||
// we should not get an error here, because `tofu validate`
|
||||
// would have complained well before this point, but if we do we'll
|
||||
// silenty skip it.
|
||||
if !diags.HasErrors() {
|
||||
@ -428,7 +428,7 @@ func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *tofu.
|
||||
dependencies := make([]string, len(mc.DependsOn))
|
||||
for i, d := range mc.DependsOn {
|
||||
ref, diags := addrs.ParseRef(d)
|
||||
// we should not get an error here, because `terraform validate`
|
||||
// we should not get an error here, because `tofu validate`
|
||||
// would have complained well before this point, but if we do we'll
|
||||
// silenty skip it.
|
||||
if !diags.HasErrors() {
|
||||
@ -501,7 +501,7 @@ func marshalResources(resources map[string]*configs.Resource, schemas *tofu.Sche
|
||||
dependencies := make([]string, len(v.DependsOn))
|
||||
for i, d := range v.DependsOn {
|
||||
ref, diags := addrs.ParseRef(d)
|
||||
// we should not get an error here, because `terraform validate`
|
||||
// we should not get an error here, because `tofu validate`
|
||||
// would have complained well before this point, but if we do we'll
|
||||
// silenty skip it.
|
||||
if !diags.HasErrors() {
|
||||
|
@ -297,7 +297,7 @@ func MarshalForLog(
|
||||
return output, nil
|
||||
}
|
||||
|
||||
// Marshal returns the json encoding of a terraform plan.
|
||||
// Marshal returns the json encoding of a tofu plan.
|
||||
func Marshal(
|
||||
config *configs.Config,
|
||||
p *plans.Plan,
|
||||
|
@ -29,7 +29,7 @@ const (
|
||||
DataResourceMode = "data"
|
||||
)
|
||||
|
||||
// State is the top-level representation of the json format of a terraform
|
||||
// State is the top-level representation of the json format of a tofu
|
||||
// state.
|
||||
type State struct {
|
||||
FormatVersion string `json:"format_version,omitempty"`
|
||||
@ -104,10 +104,10 @@ type Resource struct {
|
||||
// addresses relative to the containing module.
|
||||
DependsOn []string `json:"depends_on,omitempty"`
|
||||
|
||||
// Tainted is true if the resource is tainted in terraform state.
|
||||
// Tainted is true if the resource is tainted in tofu state.
|
||||
Tainted bool `json:"tainted,omitempty"`
|
||||
|
||||
// Deposed is set if the resource is deposed in terraform state.
|
||||
// Deposed is set if the resource is deposed in tofu state.
|
||||
DeposedKey string `json:"deposed_key,omitempty"`
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ func MarshalForLog(sf *statefile.File, schemas *tofu.Schemas) (*State, error) {
|
||||
return output, nil
|
||||
}
|
||||
|
||||
// Marshal returns the json encoding of a terraform state.
|
||||
// Marshal returns the json encoding of a tofu state.
|
||||
func Marshal(sf *statefile.File, schemas *tofu.Schemas) ([]byte, error) {
|
||||
output, err := MarshalForLog(sf, schemas)
|
||||
if err != nil {
|
||||
@ -292,7 +292,7 @@ func marshalRootModule(s *states.State, schemas *tofu.Schemas) (Module, error) {
|
||||
}
|
||||
|
||||
// marshalModules is an ungainly recursive function to build a module structure
|
||||
// out of terraform state.
|
||||
// out of tofu state.
|
||||
func marshalModules(
|
||||
s *states.State,
|
||||
schemas *tofu.Schemas,
|
||||
|
@ -50,7 +50,7 @@ type Meta struct {
|
||||
|
||||
// WorkingDir is an object representing the "working directory" where we're
|
||||
// running commands. In the normal case this literally refers to the
|
||||
// working directory of the Terraform process, though this can take on
|
||||
// working directory of the OpenTofu process, though this can take on
|
||||
// a more symbolic meaning when the user has overridden default behavior
|
||||
// to specify a different working directory or to override the special
|
||||
// data directory where we'll persist settings that must survive between
|
||||
@ -78,7 +78,7 @@ type Meta struct {
|
||||
Ui cli.Ui // Ui for output
|
||||
|
||||
// Services provides access to remote endpoint information for
|
||||
// "terraform-native' services running at a specific user-facing hostname.
|
||||
// 'tofu-native' services running at a specific user-facing hostname.
|
||||
Services *disco.Disco
|
||||
|
||||
// RunningInAutomation indicates that commands are being run by an
|
||||
@ -89,7 +89,7 @@ type Meta struct {
|
||||
// commands, since the user consuming the output will not be
|
||||
// in a position to run such commands.
|
||||
//
|
||||
// The intended use-case of this flag is when Terraform is running in
|
||||
// The intended use-case of this flag is when OpenTofu is running in
|
||||
// some sort of workflow orchestration tool which is abstracting away
|
||||
// the specific commands being run.
|
||||
RunningInAutomation bool
|
||||
@ -113,7 +113,7 @@ type Meta struct {
|
||||
// This is an accommodation for those who currently essentially ignore the
|
||||
// dependency lock file -- treating it only as transient working directory
|
||||
// state -- and therefore don't care if the plugin cache dir causes the
|
||||
// checksums inside to only be sufficient for the computer where Terraform
|
||||
// checksums inside to only be sufficient for the computer where OpenTofu
|
||||
// is currently running.
|
||||
//
|
||||
// We intend to remove this exception again (making the CLI configuration
|
||||
@ -152,16 +152,16 @@ type Meta struct {
|
||||
ProviderDevOverrides map[addrs.Provider]getproviders.PackageLocalDir
|
||||
|
||||
// UnmanagedProviders are a set of providers that exist as processes
|
||||
// predating Terraform, which Terraform should use but not worry about the
|
||||
// predating OpenTofu, which OpenTofu should use but not worry about the
|
||||
// lifecycle of.
|
||||
//
|
||||
// This is essentially a more extreme version of ProviderDevOverrides where
|
||||
// Terraform doesn't even worry about how the provider server gets launched,
|
||||
// just trusting that someone else did it before running Terraform.
|
||||
// OpenTofu doesn't even worry about how the provider server gets launched,
|
||||
// just trusting that someone else did it before running OpenTofu.
|
||||
UnmanagedProviders map[addrs.Provider]*plugin.ReattachConfig
|
||||
|
||||
// AllowExperimentalFeatures controls whether a command that embeds this
|
||||
// Meta is permitted to make use of experimental Terraform features.
|
||||
// Meta is permitted to make use of experimental OpenTofu features.
|
||||
//
|
||||
// Set this field only during the initial creation of Meta. If you change
|
||||
// this field after calling methods of type Meta then the resulting
|
||||
@ -262,7 +262,7 @@ type Meta struct {
|
||||
compactWarnings bool
|
||||
|
||||
// Used with commands which write state to allow users to write remote
|
||||
// state even if the remote and local Terraform versions don't match.
|
||||
// state even if the remote and local OpenTofu versions don't match.
|
||||
ignoreRemoteVersion bool
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ func (m *Meta) DataDir() string {
|
||||
|
||||
const (
|
||||
// InputModeEnvVar is the environment variable that, if set to "false" or
|
||||
// "0", causes terraform commands to behave as if the `-input=false` flag was
|
||||
// "0", causes tofu commands to behave as if the `-input=false` flag was
|
||||
// specified.
|
||||
InputModeEnvVar = "TF_INPUT"
|
||||
)
|
||||
@ -442,7 +442,7 @@ func (m *Meta) InterruptibleContext(base context.Context) (context.Context, cont
|
||||
//
|
||||
// This method is just a substitute for passing a context directly to the
|
||||
// "Run" method of a command, which we can't do because that API is owned by
|
||||
// mitchellh/cli rather than by Terraform. Use this only in situations
|
||||
// mitchellh/cli rather than by OpenTofu. Use this only in situations
|
||||
// comparable to the context having been passed in as an argument to Run.
|
||||
//
|
||||
// If the caller (e.g. "package main") provided a context when it instantiated
|
||||
@ -516,7 +516,7 @@ func (m *Meta) RunOperation(b backend.Enhanced, opReq *backend.Operation) (*back
|
||||
return op, nil
|
||||
}
|
||||
|
||||
// contextOpts returns the options to use to initialize a Terraform
|
||||
// contextOpts returns the options to use to initialize a OpenTofu
|
||||
// context with the settings from this Meta.
|
||||
func (m *Meta) contextOpts() (*tofu.ContextOpts, error) {
|
||||
workspace, err := m.Workspace()
|
||||
@ -563,8 +563,8 @@ func (m *Meta) defaultFlagSet(n string) *flag.FlagSet {
|
||||
}
|
||||
|
||||
// ignoreRemoteVersionFlagSet add the ignore-remote version flag to suppress
|
||||
// the error when the configured Terraform version on the remote workspace
|
||||
// does not match the local Terraform version.
|
||||
// the error when the configured OpenTofu version on the remote workspace
|
||||
// does not match the local OpenTofu version.
|
||||
func (m *Meta) ignoreRemoteVersionFlagSet(n string) *flag.FlagSet {
|
||||
f := m.defaultFlagSet(n)
|
||||
|
||||
@ -737,11 +737,11 @@ func (m *Meta) showDiagnostics(vals ...interface{}) {
|
||||
}
|
||||
|
||||
// WorkspaceNameEnvVar is the name of the environment variable that can be used
|
||||
// to set the name of the Terraform workspace, overriding the workspace chosen
|
||||
// by `terraform workspace select`.
|
||||
// to set the name of the OpenTofu workspace, overriding the workspace chosen
|
||||
// by `tofu workspace select`.
|
||||
//
|
||||
// Note that this environment variable is ignored by `terraform workspace new`
|
||||
// and `terraform workspace delete`.
|
||||
// Note that this environment variable is ignored by `tofu workspace new`
|
||||
// and `tofu workspace delete`.
|
||||
const WorkspaceNameEnvVar = "TF_WORKSPACE"
|
||||
|
||||
var errInvalidWorkspaceNameEnvVar = fmt.Errorf("Invalid workspace name set using %s", WorkspaceNameEnvVar)
|
||||
|
@ -73,8 +73,8 @@ type BackendWithRemoteTerraformVersion interface {
|
||||
|
||||
// Backend initializes and returns the backend for this CLI session.
|
||||
//
|
||||
// The backend is used to perform the actual Terraform operations. This
|
||||
// abstraction enables easily sliding in new Terraform behavior such as
|
||||
// The backend is used to perform the actual OpenTofu operations. This
|
||||
// abstraction enables easily sliding in new OpenTofu behavior such as
|
||||
// remote state storage, remote operations, etc. while allowing the CLI
|
||||
// to remain mostly identical.
|
||||
//
|
||||
@ -88,7 +88,7 @@ type BackendWithRemoteTerraformVersion interface {
|
||||
//
|
||||
// A side-effect of this method is the population of m.backendState, recording
|
||||
// the final resolved backend configuration after dealing with overrides from
|
||||
// the "terraform init" command line, etc.
|
||||
// the "tofu init" command line, etc.
|
||||
func (m *Meta) Backend(opts *BackendOpts) (backend.Enhanced, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
@ -130,7 +130,7 @@ func (m *Meta) Backend(opts *BackendOpts) (backend.Enhanced, tfdiags.Diagnostics
|
||||
}
|
||||
suggestion := "To download the plugins required for this configuration, run:\n tofu init"
|
||||
if m.RunningInAutomation {
|
||||
// Don't mention "terraform init" specifically if we're running in an automation wrapper
|
||||
// Don't mention "tofu init" specifically if we're running in an automation wrapper
|
||||
suggestion = "You must install the required plugins before running OpenTofu operations."
|
||||
}
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
@ -534,7 +534,7 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di
|
||||
// ------------------------------------------------------------------------
|
||||
// For historical reasons, current backend configuration for a working
|
||||
// directory is kept in a *state-like* file, using the legacy state
|
||||
// structures in the Terraform package. It is not actually a Terraform
|
||||
// structures in the OpenTofu package. It is not actually a OpenTofu
|
||||
// state, and so only the "backend" portion of it is actually used.
|
||||
//
|
||||
// The remainder of this code often confusingly refers to this as a "state",
|
||||
@ -545,7 +545,7 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di
|
||||
// Since the "real" state has since moved on to be represented by
|
||||
// states.State, we can recognize the special meaning of state that applies
|
||||
// to this function and its callees by their continued use of the
|
||||
// otherwise-obsolete terraform.State.
|
||||
// otherwise-obsolete tofu.State.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// Get the path to where we store a local cache of backend configuration
|
||||
@ -772,7 +772,7 @@ func (m *Meta) determineInitReason(previousBackendType string, currentBackendTyp
|
||||
|
||||
// backendFromState returns the initialized (not configured) backend directly
|
||||
// from the backend state. This should be used only when a user runs
|
||||
// `terraform init -backend=false`. This function returns a local backend if
|
||||
// `tofu init -backend=false`. This function returns a local backend if
|
||||
// there is no backend state or no backend configured.
|
||||
func (m *Meta) backendFromState(ctx context.Context) (backend.Backend, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
@ -811,7 +811,7 @@ func (m *Meta) backendFromState(ctx context.Context) (backend.Backend, tfdiags.D
|
||||
|
||||
// The configuration saved in the working directory state file is used
|
||||
// in this case, since it will contain any additional values that
|
||||
// were provided via -backend-config arguments on terraform init.
|
||||
// were provided via -backend-config arguments on tofu init.
|
||||
schema := b.ConfigSchema()
|
||||
configVal, err := s.Backend.Config(schema)
|
||||
if err != nil {
|
||||
@ -1268,7 +1268,7 @@ func (m *Meta) savedBackend(sMgr *clistate.LocalState) (backend.Backend, tfdiags
|
||||
|
||||
// The configuration saved in the working directory state file is used
|
||||
// in this case, since it will contain any additional values that
|
||||
// were provided via -backend-config arguments on terraform init.
|
||||
// were provided via -backend-config arguments on tofu init.
|
||||
schema := b.ConfigSchema()
|
||||
configVal, err := s.Backend.Config(schema)
|
||||
if err != nil {
|
||||
@ -1470,7 +1470,7 @@ func (m *Meta) ignoreRemoteVersionConflict(b backend.Backend) {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method to check the local Terraform version against the configured
|
||||
// Helper method to check the local OpenTofu version against the configured
|
||||
// version in the remote workspace, returning diagnostics if they conflict.
|
||||
func (m *Meta) remoteVersionCheck(b backend.Backend, workspace string) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
@ -1519,7 +1519,7 @@ func (m *Meta) assertSupportedCloudInitOptions(mode cloud.ConfigChangeMode) tfdi
|
||||
if m.migrateState {
|
||||
name := "-migrate-state"
|
||||
if m.forceInitCopy {
|
||||
// -force copy implies -migrate-state in "terraform init",
|
||||
// -force copy implies -migrate-state in "tofu init",
|
||||
// so m.migrateState is forced to true in this case even if
|
||||
// the user didn't actually specify it. We'll use the other
|
||||
// name here to avoid being confusing, then.
|
||||
|
@ -71,16 +71,16 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
|
||||
opts.destinationWorkspace = backend.DefaultStateName
|
||||
opts.force = m.forceInitCopy
|
||||
|
||||
// Disregard remote Terraform version for the state source backend. If it's a
|
||||
// Disregard remote OpenTofu version for the state source backend. If it's a
|
||||
// Terraform Cloud remote backend, we don't care about the remote version,
|
||||
// as we are migrating away and will not break a remote workspace.
|
||||
m.ignoreRemoteVersionConflict(opts.Source)
|
||||
|
||||
// Disregard remote Terraform version if instructed to do so via CLI flag.
|
||||
// Disregard remote OpenTofu version if instructed to do so via CLI flag.
|
||||
if m.ignoreRemoteVersion {
|
||||
m.ignoreRemoteVersionConflict(opts.Destination)
|
||||
} else {
|
||||
// Check the remote Terraform version for the state destination backend. If
|
||||
// Check the remote OpenTofu version for the state destination backend. If
|
||||
// it's a Terraform Cloud remote backend, we want to ensure that we don't
|
||||
// break the workspace by uploading an incompatible state file.
|
||||
for _, workspace := range destinationWorkspaces {
|
||||
|
@ -1933,7 +1933,7 @@ func TestBackendFromState(t *testing.T) {
|
||||
// Setup the meta
|
||||
m := testMetaBackend(t, nil)
|
||||
m.WorkingDir = wd
|
||||
// terraform caches a small "state" file that stores the backend config.
|
||||
// tofu caches a small "state" file that stores the backend config.
|
||||
// This test must override m.dataDir so it loads the "terraform.tfstate" file in the
|
||||
// test directory as the backend config cache. This fixture is really a
|
||||
// fixture for the data dir rather than the module dir, so we'll override
|
||||
|
@ -111,7 +111,7 @@ func (m *Meta) loadSingleModuleWithTests(dir string, testDir string) (*configs.M
|
||||
}
|
||||
|
||||
// dirIsConfigPath checks if the given path is a directory that contains at
|
||||
// least one Terraform configuration file (.tf or .tf.json), returning true
|
||||
// least one OpenTofu configuration file (.tf or .tf.json), returning true
|
||||
// if so.
|
||||
//
|
||||
// In the unlikely event that the underlying config loader cannot be initalized,
|
||||
@ -348,7 +348,7 @@ func (m *Meta) registerSynthConfigSource(filename string, src []byte) {
|
||||
// If the loader cannot be created for some reason then an error is returned
|
||||
// and no loader is created. Subsequent calls will presumably see the same
|
||||
// error. Loader initialization errors will tend to prevent any further use
|
||||
// of most Terraform features, so callers should report any error and safely
|
||||
// of most OpenTofu features, so callers should report any error and safely
|
||||
// terminate.
|
||||
func (m *Meta) initConfigLoader() (*configload.Loader, error) {
|
||||
if m.configLoader == nil {
|
||||
|
@ -57,7 +57,7 @@ func (m *Meta) providerInstaller() *providercache.Installer {
|
||||
// The result of providerInstallerCustomSource differs from
|
||||
// providerInstaller only in how it determines package installation locations
|
||||
// during EnsureProviderVersions. A caller that doesn't call
|
||||
// EnsureProviderVersions (anything other than "terraform init") can safely
|
||||
// EnsureProviderVersions (anything other than "tofu init") can safely
|
||||
// just use the providerInstaller method unconditionally.
|
||||
func (m *Meta) providerInstallerCustomSource(source getproviders.Source) *providercache.Installer {
|
||||
targetDir := m.providerLocalCacheDir()
|
||||
@ -83,7 +83,7 @@ func (m *Meta) providerInstallerCustomSource(source getproviders.Source) *provid
|
||||
// providerCustomLocalDirectorySource produces a provider source that consults
|
||||
// only the given local filesystem directories for plugins to install.
|
||||
//
|
||||
// This is used to implement the -plugin-dir option for "terraform init", where
|
||||
// This is used to implement the -plugin-dir option for "tofu init", where
|
||||
// the result of this method is used instead of what would've been returned
|
||||
// from m.providerInstallSource.
|
||||
//
|
||||
@ -101,10 +101,10 @@ func (m *Meta) providerCustomLocalDirectorySource(dirs []string) getproviders.So
|
||||
|
||||
// providerLocalCacheDir returns an object representing the
|
||||
// configuration-specific local cache directory. This is the
|
||||
// only location consulted for provider plugin packages for Terraform
|
||||
// only location consulted for provider plugin packages for OpenTofu
|
||||
// operations other than provider installation.
|
||||
//
|
||||
// Only the provider installer (in "terraform init") is permitted to make
|
||||
// Only the provider installer (in "tofu init") is permitted to make
|
||||
// modifications to this cache directory. All other commands must treat it
|
||||
// as read-only.
|
||||
//
|
||||
@ -141,7 +141,7 @@ func (m *Meta) providerGlobalCacheDir() *providercache.Dir {
|
||||
//
|
||||
// This returns the standard provider install source that consults a number
|
||||
// of directories selected either automatically or via the CLI configuration.
|
||||
// Users may choose to override this during a "terraform init" command by
|
||||
// Users may choose to override this during a "tofu init" command by
|
||||
// specifying one or more -plugin-dir options, in which case the installation
|
||||
// process will construct its own source consulting only those directories
|
||||
// and use that instead.
|
||||
@ -242,7 +242,7 @@ func (m *Meta) providerFactories() (map[addrs.Provider]providers.Factory, error)
|
||||
errs := make(map[addrs.Provider]error)
|
||||
|
||||
// For the providers from the lock file, we expect them to be already
|
||||
// available in the provider cache because "terraform init" should already
|
||||
// available in the provider cache because "tofu init" should already
|
||||
// have put them there.
|
||||
providerLocks := locks.AllProviders()
|
||||
cacheDir := m.providerLocalCacheDir()
|
||||
@ -260,10 +260,10 @@ func (m *Meta) providerFactories() (map[addrs.Provider]providers.Factory, error)
|
||||
// for manual testing of local development builds.
|
||||
// - The Terraform SDK test harness (and possibly other callers in future)
|
||||
// can ask that we use its own already-started provider servers, which we
|
||||
// call "unmanaged" because Terraform isn't responsible for starting
|
||||
// call "unmanaged" because OpenTofu isn't responsible for starting
|
||||
// and stopping them. This is intended for automated testing where a
|
||||
// calling harness is responsible both for starting the provider server
|
||||
// and orchestrating one or more non-interactive Terraform runs that then
|
||||
// and orchestrating one or more non-interactive OpenTofu runs that then
|
||||
// exercise it.
|
||||
// Unmanaged providers take precedence over overridden providers because
|
||||
// overrides are typically a "session-level" setting while unmanaged
|
||||
|
@ -527,8 +527,8 @@ func TestPlan_refreshTrue(t *testing.T) {
|
||||
}
|
||||
|
||||
// A consumer relies on the fact that running
|
||||
// terraform plan -refresh=false -refresh=true gives the same result as
|
||||
// terraform plan -refresh=true.
|
||||
// tofu plan -refresh=false -refresh=true gives the same result as
|
||||
// tofu plan -refresh=true.
|
||||
// While the flag logic itself is handled by the stdlib flags package (and code
|
||||
// in main() that is tested elsewhere), we verify the overall plan command
|
||||
// behaviour here in case we accidentally break this with additional logic.
|
||||
@ -890,7 +890,7 @@ func TestPlan_providerArgumentUnset(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test that terraform properly merges provider configuration that's split
|
||||
// Test that tofu properly merges provider configuration that's split
|
||||
// between config files and interactive input variables.
|
||||
// https://github.com/hashicorp/terraform/issues/28956
|
||||
func TestPlan_providerConfigMerge(t *testing.T) {
|
||||
@ -1630,7 +1630,7 @@ func planFixtureSchema() *providers.GetProviderSchemaResponse {
|
||||
// planFixtureProvider returns a mock provider that is configured for basic
|
||||
// operation with the configuration in testdata/plan. This mock has
|
||||
// GetSchemaResponse and PlanResourceChangeFn populated, with the plan
|
||||
// step just passing through the new object proposed by Terraform Core.
|
||||
// step just passing through the new object proposed by OpenTofu Core.
|
||||
func planFixtureProvider() *tofu.MockProvider {
|
||||
p := testProvider()
|
||||
p.GetProviderSchemaResponse = planFixtureSchema()
|
||||
@ -1671,7 +1671,7 @@ func planVarsFixtureSchema() *providers.GetProviderSchemaResponse {
|
||||
// planVarsFixtureProvider returns a mock provider that is configured for basic
|
||||
// operation with the configuration in testdata/plan-vars. This mock has
|
||||
// GetSchemaResponse and PlanResourceChangeFn populated, with the plan
|
||||
// step just passing through the new object proposed by Terraform Core.
|
||||
// step just passing through the new object proposed by OpenTofu Core.
|
||||
func planVarsFixtureProvider() *tofu.MockProvider {
|
||||
p := testProvider()
|
||||
p.GetProviderSchemaResponse = planVarsFixtureSchema()
|
||||
|
@ -24,7 +24,7 @@ const (
|
||||
)
|
||||
|
||||
// ProvidersLockCommand is a Command implementation that implements the
|
||||
// "terraform providers lock" command, which creates or updates the current
|
||||
// "tofu providers lock" command, which creates or updates the current
|
||||
// configuration's dependency lock file using information from upstream
|
||||
// registries, regardless of the provider installation configuration that
|
||||
// is configured for normal provider installation.
|
||||
@ -94,7 +94,7 @@ func (c *ProvidersLockCommand) Run(args []string) int {
|
||||
//
|
||||
// This is so that folks who use a local mirror for everyday use can
|
||||
// use this command to populate their lock files from upstream so
|
||||
// subsequent "terraform init" calls can then verify the local mirror
|
||||
// subsequent "tofu init" calls can then verify the local mirror
|
||||
// against the upstream checksums.
|
||||
var source getproviders.Source
|
||||
switch {
|
||||
@ -176,10 +176,10 @@ func (c *ProvidersLockCommand) Run(args []string) int {
|
||||
|
||||
// Our general strategy here is to install the requested providers into
|
||||
// a separate temporary directory -- thus ensuring that the results won't
|
||||
// ever be inadvertently executed by other Terraform commands -- and then
|
||||
// ever be inadvertently executed by other OpenTofu commands -- and then
|
||||
// use the results of that installation to update the lock file for the
|
||||
// current working directory. Because we throwaway the packages we
|
||||
// downloaded after completing our work, a subsequent "terraform init" will
|
||||
// downloaded after completing our work, a subsequent "tofu init" will
|
||||
// then respect the CLI configuration's provider installation strategies
|
||||
// but will verify the packages against the hashes we found upstream.
|
||||
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
// ProvidersMirrorCommand is a Command implementation that implements the
|
||||
// "terraform providers mirror" command, which populates a directory with
|
||||
// "tofu providers mirror" command, which populates a directory with
|
||||
// local copies of provider plugins needed by the current configuration so
|
||||
// that the mirror can be used to work offline, or similar.
|
||||
type ProvidersMirrorCommand struct {
|
||||
|
@ -75,7 +75,7 @@ func TestProvidersSchema_output(t *testing.T) {
|
||||
// flush the init output from the mock ui
|
||||
ui.OutputWriter.Reset()
|
||||
|
||||
// `terraform provider schemas` command
|
||||
// `tofu provider schemas` command
|
||||
pc := &ProvidersSchemaCommand{Meta: m}
|
||||
if code := pc.Run([]string{"-json"}); code != 0 {
|
||||
t.Fatalf("wrong exit status %d; want 0\nstderr: %s", code, ui.ErrorWriter.String())
|
||||
|
@ -43,7 +43,7 @@ func (e *errUnusableDataMisc) Unwrap() error {
|
||||
}
|
||||
|
||||
// ShowCommand is a Command implementation that reads and outputs the
|
||||
// contents of a Terraform plan or state file.
|
||||
// contents of a OpenTofu plan or state file.
|
||||
type ShowCommand struct {
|
||||
Meta
|
||||
viewType arguments.ViewType
|
||||
|
@ -360,8 +360,8 @@ func TestShow_planWithChanges(t *testing.T) {
|
||||
func TestShow_planWithForceReplaceChange(t *testing.T) {
|
||||
// The main goal of this test is to see that the "replace by request"
|
||||
// resource instance action reason can round-trip through a plan file and
|
||||
// be reflected correctly in the "terraform show" output, the same way
|
||||
// as it would appear in "terraform plan" output.
|
||||
// be reflected correctly in the "tofu show" output, the same way
|
||||
// as it would appear in "tofu plan" output.
|
||||
|
||||
_, snap := testModuleWithSnapshot(t, "show")
|
||||
plannedVal := cty.ObjectVal(map[string]cty.Value{
|
||||
@ -1053,7 +1053,7 @@ func showFixtureSensitiveSchema() *providers.GetProviderSchemaResponse {
|
||||
// operation with the configuration in testdata/show. This mock has
|
||||
// GetSchemaResponse, PlanResourceChangeFn, and ApplyResourceChangeFn populated,
|
||||
// with the plan/apply steps just passing through the data determined by
|
||||
// Terraform Core.
|
||||
// OpenTofu Core.
|
||||
func showFixtureProvider() *tofu.MockProvider {
|
||||
p := testProvider()
|
||||
p.GetProviderSchemaResponse = showFixtureSchema()
|
||||
@ -1116,7 +1116,7 @@ func showFixtureProvider() *tofu.MockProvider {
|
||||
// operation with the configuration in testdata/show. This mock has
|
||||
// GetSchemaResponse, PlanResourceChangeFn, and ApplyResourceChangeFn populated,
|
||||
// with the plan/apply steps just passing through the data determined by
|
||||
// Terraform Core. It also has a sensitive attribute in the provider schema.
|
||||
// OpenTofu Core. It also has a sensitive attribute in the provider schema.
|
||||
func showFixtureSensitiveProvider() *tofu.MockProvider {
|
||||
p := testProvider()
|
||||
p.GetProviderSchemaResponse = showFixtureSensitiveSchema()
|
||||
|
@ -463,7 +463,7 @@ func (c *StateMvCommand) sourceObjectAddrs(state *states.State, matched addrs.Ta
|
||||
// If this refers to a resource without "count" or "for_each" set then
|
||||
// we'll assume the user intended it to be a resource instance
|
||||
// address instead, to allow for requests like this:
|
||||
// terraform state mv aws_instance.foo aws_instance.bar[1]
|
||||
// tofu state mv aws_instance.foo aws_instance.bar[1]
|
||||
// That wouldn't be allowed if aws_instance.foo had multiple instances
|
||||
// since we can't move multiple instances into one.
|
||||
if rs := state.Resource(addr); rs != nil {
|
||||
|
@ -1092,7 +1092,7 @@ func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.
|
||||
}
|
||||
|
||||
// We've gathered all the values we have, let's convert them into
|
||||
// terraform.InputValues so they can be passed into the Terraform graph.
|
||||
// tofu.InputValues so they can be passed into the Terraform graph.
|
||||
|
||||
inputs := make(tofu.InputValues, len(variables))
|
||||
var diags tfdiags.Diagnostics
|
||||
@ -1103,7 +1103,7 @@ func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.
|
||||
}
|
||||
|
||||
// Next, we're going to apply any default values from the configuration.
|
||||
// We do this after the conversion into terraform.InputValues, as the
|
||||
// We do this after the conversion into tofu.InputValues, as the
|
||||
// defaults have already been converted into cty.Value objects.
|
||||
|
||||
for name, variable := range config.Module.Variables {
|
||||
|
@ -1,8 +1,8 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
// This file is a helper for those doing _manual_ testing of "terraform login"
|
||||
// and/or "terraform logout" and want to start up a test OAuth server in a
|
||||
// This file is a helper for those doing _manual_ testing of "tofu login"
|
||||
// and/or "tofu logout" and want to start up a test OAuth server in a
|
||||
// separate process for convenience:
|
||||
//
|
||||
// go run ./command/testdata/login-oauth-server/main.go :8080
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Package oauthserver is a very simplistic OAuth server used only for
|
||||
// the testing of the "terraform login" and "terraform logout" commands.
|
||||
// the testing of the "tofu login" and "tofu logout" commands.
|
||||
package oauthserver
|
||||
|
||||
import (
|
||||
@ -16,9 +16,9 @@ import (
|
||||
// Handler is an implementation of net/http.Handler that provides a stub
|
||||
// OAuth server implementation with the following endpoints:
|
||||
//
|
||||
// /authz - authorization endpoint
|
||||
// /token - token endpoint
|
||||
// /revoke - token revocation (logout) endpoint
|
||||
// /authz - authorization endpoint
|
||||
// /token - token endpoint
|
||||
// /revoke - token revocation (logout) endpoint
|
||||
//
|
||||
// The authorization endpoint returns HTML per normal OAuth conventions, but
|
||||
// it also includes an HTTP header X-Redirect-To giving the same URL that the
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Package tfeserver is a test stub implementing a subset of the TFE API used
|
||||
// only for the testing of the "terraform login" command.
|
||||
// only for the testing of the "tofu login" command.
|
||||
package tfeserver
|
||||
|
||||
import (
|
||||
@ -17,8 +17,8 @@ const (
|
||||
// Handler is an implementation of net/http.Handler that provides a stub
|
||||
// TFE API server implementation with the following endpoints:
|
||||
//
|
||||
// /ping - API existence endpoint
|
||||
// /account/details - current user endpoint
|
||||
// /ping - API existence endpoint
|
||||
// /account/details - current user endpoint
|
||||
var Handler http.Handler
|
||||
|
||||
type handler struct{}
|
||||
|
@ -51,7 +51,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// TestProvider is a wrapper around terraform.MockProvider that defines dynamic
|
||||
// TestProvider is a wrapper around tofu.MockProvider that defines dynamic
|
||||
// schemas, and keeps track of the resources and data sources that it contains.
|
||||
type TestProvider struct {
|
||||
Provider *tofu.MockProvider
|
||||
|
@ -29,7 +29,7 @@ var defaultInputWriter io.Writer
|
||||
var testInputResponse []string
|
||||
var testInputResponseMap map[string]string
|
||||
|
||||
// UIInput is an implementation of terraform.UIInput that asks the CLI
|
||||
// UIInput is an implementation of tofu.UIInput that asks the CLI
|
||||
// for input stdin.
|
||||
type UIInput struct {
|
||||
// Colorize will color the output.
|
||||
@ -67,7 +67,7 @@ func (i *UIInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, erro
|
||||
w = os.Stdout
|
||||
}
|
||||
|
||||
// Make sure we only ask for input once at a time. Terraform
|
||||
// Make sure we only ask for input once at a time. OpenTofu
|
||||
// should enforce this, but it doesn't hurt to verify.
|
||||
i.l.Lock()
|
||||
defer i.l.Unlock()
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/tofu"
|
||||
)
|
||||
|
||||
// ValidateCommand is a Command implementation that validates the terraform files
|
||||
// ValidateCommand is a Command implementation that validates the tofu files
|
||||
type ValidateCommand struct {
|
||||
Meta
|
||||
}
|
||||
@ -59,7 +59,7 @@ func (c *ValidateCommand) Run(rawArgs []string) int {
|
||||
|
||||
// Validating with dev overrides in effect means that the result might
|
||||
// not be valid for a stable release, so we'll warn about that in case
|
||||
// the user is trying to use "terraform validate" as a sort of pre-flight
|
||||
// the user is trying to use "tofu validate" as a sort of pre-flight
|
||||
// check before submitting a change.
|
||||
diags = diags.Append(c.providerDevOverrideRuntimeWarnings())
|
||||
|
||||
@ -105,8 +105,8 @@ func (c *ValidateCommand) validate(dir, testDir string, noTests bool) tfdiags.Di
|
||||
|
||||
validatedModules := make(map[string]bool)
|
||||
|
||||
// We'll also do a quick validation of the Terraform test files. These live
|
||||
// outside the Terraform graph so we have to do this separately.
|
||||
// We'll also do a quick validation of the OpenTofu test files. These live
|
||||
// outside the OpenTofu graph so we have to do this separately.
|
||||
for _, file := range cfg.Module.Tests {
|
||||
for _, run := range file.Runs {
|
||||
|
||||
@ -117,7 +117,7 @@ func (c *ValidateCommand) validate(dir, testDir string, noTests bool) tfdiags.Di
|
||||
// Basically, local testing modules are something the user can
|
||||
// reasonably go and fix. If it's a module being downloaded from
|
||||
// the registry, the expectation is that the author of the
|
||||
// module should have ran `terraform validate` themselves.
|
||||
// module should have ran `tofu validate` themselves.
|
||||
if _, ok := run.Module.Source.(addrs.ModuleSourceLocal); ok {
|
||||
|
||||
if validated := validatedModules[run.Module.Source.String()]; !validated {
|
||||
|
@ -68,11 +68,11 @@ func (c *VersionCommand) Run(args []string) int {
|
||||
|
||||
// We'll also attempt to print out the selected plugin versions. We do
|
||||
// this based on the dependency lock file, and so the result might be
|
||||
// empty or incomplete if the user hasn't successfully run "terraform init"
|
||||
// empty or incomplete if the user hasn't successfully run "tofu init"
|
||||
// since the most recent change to dependencies.
|
||||
//
|
||||
// Generally-speaking this is a best-effort thing that will give us a good
|
||||
// result in the usual case where the user successfully ran "terraform init"
|
||||
// result in the usual case where the user successfully ran "tofu init"
|
||||
// and then hit a problem running _another_ command.
|
||||
var providerVersions []string
|
||||
var providerLocks map[addrs.Provider]*depsfile.ProviderLock
|
||||
|
@ -70,7 +70,7 @@ func TestVersion_flags(t *testing.T) {
|
||||
Ui: ui,
|
||||
}
|
||||
|
||||
// `terraform version`
|
||||
// `tofu version`
|
||||
c := &VersionCommand{
|
||||
Meta: m,
|
||||
Version: "4.5.6",
|
||||
@ -98,7 +98,7 @@ func TestVersion_json(t *testing.T) {
|
||||
Ui: ui,
|
||||
}
|
||||
|
||||
// `terraform version -json` without prerelease
|
||||
// `tofu version -json` without prerelease
|
||||
c := &VersionCommand{
|
||||
Meta: meta,
|
||||
Version: "4.5.6",
|
||||
@ -140,7 +140,7 @@ func TestVersion_json(t *testing.T) {
|
||||
nil,
|
||||
)
|
||||
|
||||
// `terraform version -json` with prerelease and provider dependencies
|
||||
// `tofu version -json` with prerelease and provider dependencies
|
||||
c = &VersionCommand{
|
||||
Meta: meta,
|
||||
Version: "4.5.6",
|
||||
|
@ -36,7 +36,7 @@ func NewValidate(vt arguments.ViewType, view *View) Validate {
|
||||
}
|
||||
|
||||
// The ValidateHuman implementation renders diagnostics in a human-readable form,
|
||||
// along with a success/failure message if Terraform is able to execute the
|
||||
// along with a success/failure message if OpenTofu is able to execute the
|
||||
// validation walk.
|
||||
type ValidateHuman struct {
|
||||
view *View
|
||||
|
@ -20,7 +20,7 @@ type View struct {
|
||||
|
||||
compactWarnings bool
|
||||
|
||||
// When this is true it's a hint that Terraform is being run indirectly
|
||||
// When this is true it's a hint that OpenTofu is being run indirectly
|
||||
// via a wrapper script or other automation and so we may wish to replace
|
||||
// direct examples of commands to run with more conceptual directions.
|
||||
// However, we only do this on a best-effort basis, typically prioritizing
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Dir represents a single Terraform working directory.
|
||||
// Dir represents a single OpenTofu working directory.
|
||||
//
|
||||
// "Working directory" is unfortunately a slight misnomer, because non-default
|
||||
// options can potentially stretch the definition such that multiple working
|
||||
@ -36,13 +36,13 @@ import (
|
||||
type Dir struct {
|
||||
// mainDir is the path to the directory that we present as the
|
||||
// "working directory" in the user model, which is typically the
|
||||
// current working directory when running Terraform CLI, or the
|
||||
// current working directory when running OpenTofu CLI, or the
|
||||
// directory explicitly chosen by the user using the -chdir=...
|
||||
// global option.
|
||||
mainDir string
|
||||
|
||||
// originalDir is the path to the working directory that was
|
||||
// selected when creating the Terraform CLI process, regardless of
|
||||
// selected when creating the OpenTofu CLI process, regardless of
|
||||
// -chdir=... being set. This is only for very limited purposes
|
||||
// related to backward compatibility; most functionality should
|
||||
// use mainDir instead.
|
||||
@ -84,7 +84,7 @@ func NewDir(mainPath string) *Dir {
|
||||
// OverrideOriginalWorkingDir records a different path as the
|
||||
// "original working directory" for the reciever.
|
||||
//
|
||||
// Use this only to record the original working directory when Terraform is run
|
||||
// Use this only to record the original working directory when OpenTofu is run
|
||||
// with the -chdir=... global option. In that case, the directory given in
|
||||
// -chdir=... is the "main path" to pass in to NewDir, while the original
|
||||
// working directory should be sent to this method.
|
||||
@ -112,10 +112,10 @@ func (d *Dir) RootModuleDir() string {
|
||||
}
|
||||
|
||||
// OriginalWorkingDir returns the true, operating-system-originated working
|
||||
// directory that the current Terraform process was launched from.
|
||||
// directory that the current OpenTofu process was launched from.
|
||||
//
|
||||
// This is usually the same as the main working directory, but differs in the
|
||||
// special case where the user ran Terraform with the global -chdir=...
|
||||
// special case where the user ran OpenTofu with the global -chdir=...
|
||||
// option. This is here only for a few backward compatibility affordances
|
||||
// from before we had the -chdir=... option, so should typically not be used
|
||||
// for anything new.
|
||||
@ -140,7 +140,7 @@ func (d *Dir) DataDir() string {
|
||||
//
|
||||
// For directories that already exist ensureDataDir will preserve their
|
||||
// permissions, while it'll create any new directories to be owned by the user
|
||||
// running Terraform, readable and writable by that user, and readable by
|
||||
// running OpenTofu, readable and writable by that user, and readable by
|
||||
// all other users, or some approximation of that on non-Unix platforms which
|
||||
// have a different permissions model.
|
||||
func (d *Dir) ensureDataDir() error {
|
||||
|
@ -2,14 +2,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package workdir models the various local artifacts and state we keep inside
|
||||
// a Terraform "working directory".
|
||||
// a OpenTofu "working directory".
|
||||
//
|
||||
// The working directory artifacts and settings are typically initialized or
|
||||
// modified by "terraform init", after which they persist for use by other
|
||||
// modified by "tofu init", after which they persist for use by other
|
||||
// commands in the same directory, but are not visible to commands run in
|
||||
// other working directories or on other computers.
|
||||
//
|
||||
// Although "terraform init" is the main command which modifies a workdir,
|
||||
// Although "tofu init" is the main command which modifies a workdir,
|
||||
// other commands do sometimes make more focused modifications for settings
|
||||
// which can typically change multiple times during a session, such as the
|
||||
// currently-selected workspace name. Any command which modifies the working
|
||||
|
@ -329,7 +329,7 @@ func buildSSHClientConfig(opts sshClientConfigOpts) (*ssh.ClientConfig, error) {
|
||||
hkCallback := ssh.InsecureIgnoreHostKey()
|
||||
|
||||
if opts.hostKey != "" {
|
||||
// The knownhosts package only takes paths to files, but terraform
|
||||
// The knownhosts package only takes paths to files, but tofu
|
||||
// generally wants to handle config data in-memory. Rather than making
|
||||
// the known_hosts file an exception, write out the data to a temporary
|
||||
// file to create the HostKeyCallback.
|
||||
|
@ -149,7 +149,7 @@ var checkRuleBlockSchema = &hcl.BodySchema{
|
||||
//
|
||||
// A check block contains 0-1 data blocks, and 0-n assert blocks. The check
|
||||
// block will load the data block, and execute the assert blocks as check rules
|
||||
// during the plan and apply Terraform operations.
|
||||
// during the plan and apply OpenTofu operations.
|
||||
type Check struct {
|
||||
Name string
|
||||
|
||||
|
@ -195,7 +195,7 @@ func (c *Config) DescendentForInstance(path addrs.ModuleInstance) *Config {
|
||||
// directly via a remote source address or indirectly via a registry source
|
||||
// address.
|
||||
//
|
||||
// Other behaviors in Terraform may treat package crossings as a special
|
||||
// Other behaviors in OpenTofu may treat package crossings as a special
|
||||
// situation, because that indicates that the caller and callee can change
|
||||
// independently of one another and thus we should disallow using any features
|
||||
// where the caller assumes anything about the callee other than its input
|
||||
@ -217,11 +217,11 @@ func (c *Config) EntersNewPackage() bool {
|
||||
// multiple inconsistencies then it will attempt to describe as many of them
|
||||
// as possible, rather than stopping at the first problem.
|
||||
//
|
||||
// It's typically the responsibility of "terraform init" to change the locked
|
||||
// It's typically the responsibility of "tofu init" to change the locked
|
||||
// dependencies to conform with the configuration, and so
|
||||
// VerifyDependencySelections is intended for other commands to check whether
|
||||
// it did so correctly and to catch if anything has changed in configuration
|
||||
// since the last "terraform init" which requires re-initialization. However,
|
||||
// since the last "tofu init" which requires re-initialization. However,
|
||||
// it's up to the caller to decide how to advise users recover from these
|
||||
// errors, because the advise can vary depending on what operation the user
|
||||
// is attempting.
|
||||
@ -486,7 +486,7 @@ func (c *Config) addProviderRequirements(reqs getproviders.Requirements, recurse
|
||||
if i.ProviderConfigRef.Name != target.ProviderConfigRef.Name || i.ProviderConfigRef.Alias != target.ProviderConfigRef.Alias {
|
||||
// This means we have a provider specified in both the
|
||||
// import block and the resource block, and they disagree.
|
||||
// This is bad as Terraform now has different instructions
|
||||
// This is bad as OpenTofu now has different instructions
|
||||
// about which provider to use.
|
||||
//
|
||||
// The general guidance is that only the resource should be
|
||||
@ -882,7 +882,7 @@ func (c *Config) TransformForTest(run *TestRun, file *TestFile) (func(), hcl.Dia
|
||||
//
|
||||
// We can have a set of providers defined within the config, we can also
|
||||
// have a set of providers defined within the test file. Then the run can
|
||||
// also specify a set of overrides that tell Terraform exactly which
|
||||
// also specify a set of overrides that tell OpenTofu exactly which
|
||||
// providers from the test file to apply into the config.
|
||||
//
|
||||
// The process here is as follows:
|
||||
|
@ -34,7 +34,7 @@ type Config struct {
|
||||
// ModulesDir is a path to a directory where descendent modules are
|
||||
// (or should be) installed. (This is usually the
|
||||
// .terraform/modules directory, in the common case where this package
|
||||
// is being loaded from the main Terraform CLI package.)
|
||||
// is being loaded from the main OpenTofu CLI package.)
|
||||
ModulesDir string
|
||||
|
||||
// Services is the service discovery client to use when locating remote
|
||||
@ -114,7 +114,7 @@ func (l *Loader) Sources() map[string][]byte {
|
||||
}
|
||||
|
||||
// IsConfigDir returns true if and only if the given directory contains at
|
||||
// least one Terraform configuration file. This is a wrapper around calling
|
||||
// least one OpenTofu configuration file. This is a wrapper around calling
|
||||
// the same method name on the loader's parser.
|
||||
func (l *Loader) IsConfigDir(path string) bool {
|
||||
return l.parser.IsConfigDir(path)
|
||||
|
@ -55,7 +55,7 @@ func (l *Loader) moduleWalkerLoad(req *configs.ModuleRequest) (*configs.Module,
|
||||
// Since we're just loading here, we expect that all referenced modules
|
||||
// will be already installed and described in our manifest. However, we
|
||||
// do verify that the manifest and the configuration are in agreement
|
||||
// so that we can prompt the user to run "terraform init" if not.
|
||||
// so that we can prompt the user to run "tofu init" if not.
|
||||
|
||||
key := l.modules.manifest.ModuleKey(req.Path)
|
||||
record, exists := l.modules.manifest[key]
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
// For example, this is used to describe the expected contents of a resource
|
||||
// configuration block, which is defined by the corresponding provider plugin
|
||||
// and thus not compiled into Terraform core.
|
||||
// and thus not compiled into OpenTofu core.
|
||||
//
|
||||
// A configschema primarily describes the shape of configuration, but it is
|
||||
// also suitable for use with other structures derived from the configuration,
|
||||
|
@ -19,7 +19,7 @@ var validName = regexp.MustCompile(`^[a-z0-9_]+$`)
|
||||
// schema.
|
||||
//
|
||||
// This can be used within unit tests to detect when a given schema is invalid,
|
||||
// and is run when terraform loads provider schemas during NewContext.
|
||||
// and is run when tofu loads provider schemas during NewContext.
|
||||
func (b *Block) InternalValidate() error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("top-level block schema is nil")
|
||||
|
@ -1,18 +1,18 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package configs contains types that represent Terraform configurations and
|
||||
// Package configs contains types that represent OpenTofu configurations and
|
||||
// the different elements thereof.
|
||||
//
|
||||
// The functionality in this package can be used for some static analyses of
|
||||
// Terraform configurations, but this package generally exposes representations
|
||||
// OpenTofu configurations, but this package generally exposes representations
|
||||
// of the configuration source code rather than the result of evaluating these
|
||||
// objects. The sibling package "lang" deals with evaluation of structures
|
||||
// and expressions in the configuration.
|
||||
//
|
||||
// Due to its close relationship with HCL, this package makes frequent use
|
||||
// of types from the HCL API, including raw HCL diagnostic messages. Such
|
||||
// diagnostics can be converted into Terraform-flavored diagnostics, if needed,
|
||||
// diagnostics can be converted into OpenTofu-flavored diagnostics, if needed,
|
||||
// using functions in the sibling package tfdiags.
|
||||
//
|
||||
// The Parser type is the main entry-point into this package. The LoadConfigDir
|
||||
|
@ -19,10 +19,10 @@ import (
|
||||
//
|
||||
// This must be used _only_ for comparing values for equivalence within the
|
||||
// SDK planning code. It is only meaningful to compare the "prior state"
|
||||
// provided by Terraform Core with the "planned new state" produced by the
|
||||
// provided by OpenTofu Core with the "planned new state" produced by the
|
||||
// legacy SDK code via shims. In particular it is not valid to use this
|
||||
// function with their the config value or the "proposed new state" value
|
||||
// because they contain only the subset of data that Terraform Core itself is
|
||||
// because they contain only the subset of data that OpenTofu Core itself is
|
||||
// able to determine.
|
||||
func ValuesSDKEquivalent(a, b cty.Value) bool {
|
||||
if a == cty.NilVal || b == cty.NilVal {
|
||||
@ -183,7 +183,7 @@ func valuesSDKEquivalentMappings(a, b cty.Value) bool {
|
||||
|
||||
// valuesSDKEquivalentNumbers decides equivalence for two number values based
|
||||
// on the fact that the SDK uses int and float64 representations while
|
||||
// cty (and thus Terraform Core) uses big.Float, and so we expect to lose
|
||||
// cty (and thus OpenTofu Core) uses big.Float, and so we expect to lose
|
||||
// precision in the round-trip.
|
||||
//
|
||||
// This does _not_ attempt to allow for an epsilon difference that may be
|
||||
|
@ -32,7 +32,7 @@ func (p *Parser) LoadConfigFileOverride(path string) (*File, hcl.Diagnostics) {
|
||||
return p.loadConfigFile(path, true)
|
||||
}
|
||||
|
||||
// LoadTestFile reads the file at the given path and parses it as a Terraform
|
||||
// LoadTestFile reads the file at the given path and parses it as a OpenTofu
|
||||
// test file.
|
||||
//
|
||||
// It references the same LoadHCLFile as LoadConfigFile, so inherits the same
|
||||
@ -211,7 +211,7 @@ func (p *Parser) loadConfigFile(path string, override bool) (*File, hcl.Diagnost
|
||||
//
|
||||
// This is intended to maximize the chance that we'll be able to read the
|
||||
// requirements (syntax errors notwithstanding) even if the config file contains
|
||||
// constructs that might've been added in future Terraform versions
|
||||
// constructs that might've been added in future OpenTofu versions
|
||||
//
|
||||
// This is a "best effort" sort of method which will return constraints it is
|
||||
// able to find, but may return no constraints at all if the given body is
|
||||
|
@ -95,7 +95,7 @@ func (p Parser) ConfigDirFilesWithTests(dir string, testDirectory string) (prima
|
||||
}
|
||||
|
||||
// IsConfigDir determines whether the given path refers to a directory that
|
||||
// exists and contains at least one Terraform config file (with a .tf or
|
||||
// exists and contains at least one OpenTofu config file (with a .tf or
|
||||
// .tf.json extension.). Note, we explicitely exclude checking for tests here
|
||||
// as tests must live alongside actual .tf config files.
|
||||
func (p *Parser) IsConfigDir(path string) bool {
|
||||
@ -124,10 +124,10 @@ func (p *Parser) loadFiles(paths []string, override bool) ([]*File, hcl.Diagnost
|
||||
return files, diags
|
||||
}
|
||||
|
||||
// dirFiles finds Terraform configuration files within dir, splitting them into
|
||||
// dirFiles finds OpenTofu configuration files within dir, splitting them into
|
||||
// primary and override files based on the filename.
|
||||
//
|
||||
// If testsDir is not empty, dirFiles will also retrieve Terraform testing files
|
||||
// If testsDir is not empty, dirFiles will also retrieve OpenTofu testing files
|
||||
// both directly within dir and within testsDir as a subdirectory of dir. In
|
||||
// this way, testsDir acts both as a direction to retrieve test files within the
|
||||
// main direction and as the location for additional test files.
|
||||
@ -196,7 +196,7 @@ func (p *Parser) dirFiles(dir string, testsDir string) (primary, override, tests
|
||||
|
||||
for _, info := range infos {
|
||||
if info.IsDir() {
|
||||
// We only care about terraform configuration files.
|
||||
// We only care about tofu configuration files.
|
||||
continue
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ func (p *Parser) loadTestFiles(basePath string, paths []string) (map[string]*Tes
|
||||
return tfs, diags
|
||||
}
|
||||
|
||||
// fileExt returns the Terraform configuration extension of the given
|
||||
// fileExt returns the OpenTofu configuration extension of the given
|
||||
// path, or a blank string if it is not a recognized extension.
|
||||
func fileExt(path string) string {
|
||||
if strings.HasSuffix(path, ".tf") {
|
||||
@ -277,7 +277,7 @@ func IsIgnoredFile(name string) bool {
|
||||
strings.HasPrefix(name, "#") && strings.HasSuffix(name, "#") // emacs
|
||||
}
|
||||
|
||||
// IsEmptyDir returns true if the given filesystem path contains no Terraform
|
||||
// IsEmptyDir returns true if the given filesystem path contains no OpenTofu
|
||||
// configuration files.
|
||||
//
|
||||
// Unlike the methods of the Parser type, this function always consults the
|
||||
|
@ -11,20 +11,20 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/tfdiags"
|
||||
)
|
||||
|
||||
// TestCommand represents the Terraform a given run block will execute, plan
|
||||
// TestCommand represents the OpenTofu a given run block will execute, plan
|
||||
// or apply. Defaults to apply.
|
||||
type TestCommand rune
|
||||
|
||||
// TestMode represents the plan mode that Terraform will use for a given run
|
||||
// TestMode represents the plan mode that OpenTofu will use for a given run
|
||||
// block, normal or refresh-only. Defaults to normal.
|
||||
type TestMode rune
|
||||
|
||||
const (
|
||||
// ApplyTestCommand causes the run block to execute a Terraform apply
|
||||
// ApplyTestCommand causes the run block to execute a OpenTofu apply
|
||||
// operation.
|
||||
ApplyTestCommand TestCommand = 0
|
||||
|
||||
// PlanTestCommand causes the run block to execute a Terraform plan
|
||||
// PlanTestCommand causes the run block to execute a OpenTofu plan
|
||||
// operation.
|
||||
PlanTestCommand TestCommand = 'P'
|
||||
|
||||
@ -36,7 +36,7 @@ const (
|
||||
RefreshOnlyTestMode TestMode = 'R'
|
||||
)
|
||||
|
||||
// TestFile represents a single test file within a `terraform test` execution.
|
||||
// TestFile represents a single test file within a `tofu test` execution.
|
||||
//
|
||||
// A test file is made up of a sequential list of run blocks, each designating
|
||||
// a command to execute and a series of validations to check after the command.
|
||||
@ -61,12 +61,12 @@ type TestFile struct {
|
||||
|
||||
// TestRun represents a single run block within a test file.
|
||||
//
|
||||
// Each run block represents a single Terraform command to be executed and a set
|
||||
// Each run block represents a single OpenTofu command to be executed and a set
|
||||
// of validations to run after the command.
|
||||
type TestRun struct {
|
||||
Name string
|
||||
|
||||
// Command is the Terraform command to execute.
|
||||
// Command is the OpenTofu command to execute.
|
||||
//
|
||||
// One of ['apply', 'plan'].
|
||||
Command TestCommand
|
||||
@ -108,7 +108,7 @@ type TestRun struct {
|
||||
// against.
|
||||
//
|
||||
// In typical cases, this will be null and the config under test is the
|
||||
// configuration within the directory the terraform test command is
|
||||
// configuration within the directory the tofu test command is
|
||||
// executing within. However, when Module is set the config under test is
|
||||
// whichever config is defined by Module. This field is then set during the
|
||||
// configuration load process and should be used when the test is executed.
|
||||
@ -175,13 +175,13 @@ type TestRunOptions struct {
|
||||
// Mode is the planning mode to run in. One of ['normal', 'refresh-only'].
|
||||
Mode TestMode
|
||||
|
||||
// Refresh is analogous to the -refresh=false Terraform plan option.
|
||||
// Refresh is analogous to the -refresh=false OpenTofu plan option.
|
||||
Refresh bool
|
||||
|
||||
// Replace is analogous to the -refresh=ADDRESS Terraform plan option.
|
||||
// Replace is analogous to the -refresh=ADDRESS OpenTofu plan option.
|
||||
Replace []hcl.Traversal
|
||||
|
||||
// Target is analogous to the -target=ADDRESS Terraform plan option.
|
||||
// Target is analogous to the -target=ADDRESS OpenTofu plan option.
|
||||
Target []hcl.Traversal
|
||||
|
||||
DeclRange hcl.Range
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// VersionConstraint represents a version constraint on some resource
|
||||
// (e.g. Terraform Core, a provider, a module, ...) that carries with it
|
||||
// (e.g. OpenTofu Core, a provider, a module, ...) that carries with it
|
||||
// a source range so that a helpful diagnostic can be printed in the event
|
||||
// that a particular constraint does not match.
|
||||
type VersionConstraint struct {
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Package depsfile contains the logic for reading and writing OpenTofu's
|
||||
// dependency lock and development override configuration files.
|
||||
//
|
||||
// These files are separate from the main Terraform configuration files (.tf)
|
||||
// These files are separate from the main OpenTofu configuration files (.tf)
|
||||
// for a number of reasons. The first is to help establish a distinction
|
||||
// where .tf files configure a particular module while these configure
|
||||
// a whole configuration tree. Another, more practical consideration is that
|
||||
|
@ -112,7 +112,7 @@ func (b *binary) AddEnv(entry string) {
|
||||
b.env = append(b.env, entry)
|
||||
}
|
||||
|
||||
// Cmd returns an exec.Cmd pre-configured to run the generated Terraform
|
||||
// Cmd returns an exec.Cmd pre-configured to run the generated OpenTofu
|
||||
// binary with the given arguments in the temporary working directory.
|
||||
//
|
||||
// The returned object can be mutated by the caller to customize how the
|
||||
@ -127,10 +127,10 @@ func (b *binary) Cmd(args ...string) *exec.Cmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Run executes the generated Terraform binary with the given arguments
|
||||
// Run executes the generated OpenTofu binary with the given arguments
|
||||
// and returns the bytes that it wrote to both stdout and stderr.
|
||||
//
|
||||
// This is a simple way to run Terraform for non-interactive commands
|
||||
// This is a simple way to run OpenTofu for non-interactive commands
|
||||
// that don't need any special environment variables. For more complex
|
||||
// situations, use Cmd and customize the command before running it.
|
||||
func (b *binary) Run(args ...string) (stdout, stderr string, err error) {
|
||||
|
@ -75,7 +75,7 @@ func (e Experiment) IsConcluded() bool {
|
||||
}
|
||||
|
||||
// currentExperiments are those which are available to activate in the current
|
||||
// version of Terraform.
|
||||
// version of OpenTofu.
|
||||
//
|
||||
// Members of this set are registered in the init function above.
|
||||
var currentExperiments = make(Set)
|
||||
|
@ -174,7 +174,7 @@ func findLegacyProviderLookupSource(host svchost.Hostname, source Source) *Regis
|
||||
// This method exists only to allow compatibility with unqualified names
|
||||
// in older configurations. New configurations should be written so as not to
|
||||
// depend on it, and this fallback mechanism will likely be removed altogether
|
||||
// in a future Terraform version.
|
||||
// in a future OpenTofu version.
|
||||
func (s *RegistrySource) lookupLegacyProviderNamespace(ctx context.Context, hostname svchost.Hostname, typeName string) (string, string, error) {
|
||||
client, err := s.registryClient(hostname)
|
||||
if err != nil {
|
||||
|
@ -36,7 +36,7 @@ const NilHash = Hash("")
|
||||
|
||||
// ParseHash parses the string representation of a Hash into a Hash value.
|
||||
//
|
||||
// A particular version of Terraform only supports a fixed set of hash schemes,
|
||||
// A particular version of OpenTofu only supports a fixed set of hash schemes,
|
||||
// but this function intentionally allows unrecognized schemes so that we can
|
||||
// silently ignore other schemes that may be introduced in the future. For
|
||||
// that reason, the Scheme method of the returned Hash may return a value that
|
||||
@ -116,7 +116,7 @@ func (h Hash) GoString() string {
|
||||
return fmt.Sprintf("getproviders.HashSchemeZip.New(%q)", h.Value())
|
||||
default:
|
||||
// This fallback is for when we encounter lock files or API responses
|
||||
// with hash schemes that the current version of Terraform isn't
|
||||
// with hash schemes that the current version of OpenTofu isn't
|
||||
// familiar with. They were presumably introduced in a later version.
|
||||
return fmt.Sprintf("getproviders.HashScheme(%q).New(%q)", scheme, h.Value())
|
||||
}
|
||||
@ -261,7 +261,7 @@ func PackageMatchesAnyHash(loc PackageLocation, allowed []Hash) (bool, error) {
|
||||
}
|
||||
|
||||
// PreferredHashes examines all of the given hash strings and returns the one
|
||||
// that the current version of Terraform considers to provide the strongest
|
||||
// that the current version of OpenTofu considers to provide the strongest
|
||||
// verification.
|
||||
//
|
||||
// Returns an empty string if none of the given hashes are of a supported
|
||||
@ -356,7 +356,7 @@ func PackageHashV1(loc PackageLocation) (Hash, error) {
|
||||
// changes by being used in a wide array of go.sum files already.
|
||||
//
|
||||
// In particular, it also supports computing an equivalent hash from
|
||||
// an unpacked zip file, which is not important for Terraform workflow
|
||||
// an unpacked zip file, which is not important for OpenTofu workflow
|
||||
// today but is likely to become so in future if we adopt a top-level
|
||||
// lockfile mechanism that is intended to be checked in to version control,
|
||||
// rather than just a transient lock for a particular local cache directory.
|
||||
|
@ -134,7 +134,7 @@ type PackageAuthenticationHashes interface {
|
||||
// hashes with different schemes, which means that all of them are equally
|
||||
// acceptable. Implementors may also return hashes that use schemes the
|
||||
// current version of the authenticator would not allow but that could be
|
||||
// accepted by other versions of Terraform, e.g. if a particular hash
|
||||
// accepted by other versions of OpenTofu, e.g. if a particular hash
|
||||
// scheme has been deprecated.
|
||||
//
|
||||
// Authenticators that don't use hashes as their authentication procedure
|
||||
@ -202,11 +202,11 @@ type packageHashAuthentication struct {
|
||||
|
||||
// NewPackageHashAuthentication returns a PackageAuthentication implementation
|
||||
// that checks whether the contents of the package match whatever subset of the
|
||||
// given hashes are considered acceptable by the current version of Terraform.
|
||||
// given hashes are considered acceptable by the current version of OpenTofu.
|
||||
//
|
||||
// This uses the hash algorithms implemented by functions PackageHash and
|
||||
// MatchesHash. The PreferredHashes function will select which of the given
|
||||
// hashes are considered by Terraform to be the strongest verification, and
|
||||
// hashes are considered by OpenTofu to be the strongest verification, and
|
||||
// authentication succeeds as long as one of those matches.
|
||||
func NewPackageHashAuthentication(platform Platform, validHashes []Hash) PackageAuthentication {
|
||||
requiredHashes := PreferredHashes(validHashes)
|
||||
@ -221,7 +221,7 @@ func (a packageHashAuthentication) AuthenticatePackage(localLocation PackageLoca
|
||||
if len(a.RequiredHashes) == 0 {
|
||||
// Indicates that none of the hashes given to
|
||||
// NewPackageHashAuthentication were considered to be usable by this
|
||||
// version of Terraform.
|
||||
// version of OpenTofu.
|
||||
return nil, fmt.Errorf("this version of OpenTofu does not support any of the checksum formats given for this provider")
|
||||
}
|
||||
|
||||
@ -247,9 +247,9 @@ func (a packageHashAuthentication) AuthenticatePackage(localLocation PackageLoca
|
||||
}
|
||||
|
||||
func (a packageHashAuthentication) AcceptableHashes() []Hash {
|
||||
// In this case we include even hashes the current version of Terraform
|
||||
// In this case we include even hashes the current version of OpenTofu
|
||||
// doesn't prefer, because this result is used for building a lock file
|
||||
// and so it's helpful to include older hash formats that other Terraform
|
||||
// and so it's helpful to include older hash formats that other OpenTofu
|
||||
// versions might need in order to do authentication successfully.
|
||||
return a.AllHashes
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ var CurrentPlatform = Platform{
|
||||
// Package findproviders does no signature verification or protocol version
|
||||
// compatibility checking of its own. A caller receving a PackageMeta must
|
||||
// verify that it has a correct signature and supports a protocol version
|
||||
// accepted by the current version of Terraform before trying to use the
|
||||
// accepted by the current version of OpenTofu before trying to use the
|
||||
// described package.
|
||||
type PackageMeta struct {
|
||||
Provider addrs.Provider
|
||||
@ -255,7 +255,7 @@ func (m PackageMeta) PackedFilePath(baseDir string) string {
|
||||
// intent that in most cases it will be used as an additional cross-check in
|
||||
// addition to a platform-specific hash check made during installation. However,
|
||||
// there are some situations (such as verifying an already-installed package
|
||||
// that's on local disk) where Terraform would check only against the results
|
||||
// that's on local disk) where OpenTofu would check only against the results
|
||||
// of this function, meaning that it would in principle accept another
|
||||
// platform's package as a substitute for the correct platform. That's a
|
||||
// pragmatic compromise to allow lock files derived from the result of this
|
||||
@ -291,7 +291,7 @@ type PackageLocation interface {
|
||||
// PackageLocalArchive is the location of a provider distribution archive file
|
||||
// in the local filesystem. Its value is a local filesystem path using the
|
||||
// syntax understood by Go's standard path/filepath package on the operating
|
||||
// system where Terraform is running.
|
||||
// system where OpenTofu is running.
|
||||
type PackageLocalArchive string
|
||||
|
||||
func (p PackageLocalArchive) packageLocation() {}
|
||||
@ -300,7 +300,7 @@ func (p PackageLocalArchive) String() string { return string(p) }
|
||||
// PackageLocalDir is the location of a directory containing an unpacked
|
||||
// provider distribution archive in the local filesystem. Its value is a local
|
||||
// filesystem path using the syntax understood by Go's standard path/filepath
|
||||
// package on the operating system where Terraform is running.
|
||||
// package on the operating system where OpenTofu is running.
|
||||
type PackageLocalDir string
|
||||
|
||||
func (p PackageLocalDir) packageLocation() {}
|
||||
@ -387,7 +387,7 @@ func (l PackageMetaList) FilterProviderPlatformExactVersion(provider addrs.Provi
|
||||
func VersionConstraintsString(spec VersionConstraints) string {
|
||||
// (we have our own function for this because the upstream versions
|
||||
// library prefers to use npm/cargo-style constraint syntax, but
|
||||
// Terraform prefers Ruby-like. Maybe we can upstream a "RubyLikeString")
|
||||
// OpenTofu prefers Ruby-like. Maybe we can upstream a "RubyLikeString")
|
||||
// function to do this later, but having this in here avoids blocking on
|
||||
// that and this is the sort of thing that is unlikely to need ongoing
|
||||
// maintenance because the version constraint syntax is unlikely to change.)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// New returns the DefaultPooledClient from the cleanhttp
|
||||
// package that will also send a Terraform User-Agent string.
|
||||
// package that will also send a OpenTofu User-Agent string.
|
||||
func New() *http.Client {
|
||||
cli := cleanhttp.DefaultPooledClient()
|
||||
cli.Transport = &userAgentRoundTripper{
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package acctest contains for Terraform Acceptance Tests
|
||||
// Package acctest contains for OpenTofu Acceptance Tests
|
||||
package acctest
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
|
||||
// The functions and methods in this file are concerned with the conversion
|
||||
// of this package's schema model into the slightly-lower-level schema model
|
||||
// used by Terraform core for configuration parsing.
|
||||
// used by OpenTofu core for configuration parsing.
|
||||
|
||||
// CoreConfigSchema lowers the receiver to the schema model expected by
|
||||
// Terraform core.
|
||||
// OpenTofu core.
|
||||
//
|
||||
// This lower-level model has fewer features than the schema in this package,
|
||||
// describing only the basic structure of configuration and state values we
|
||||
@ -91,7 +91,7 @@ func (m schemaMap) CoreConfigSchema() *configschema.Block {
|
||||
func (s *Schema) coreConfigSchemaAttribute() *configschema.Attribute {
|
||||
// The Schema.DefaultFunc capability adds some extra weirdness here since
|
||||
// it can be combined with "Required: true" to create a situation where
|
||||
// required-ness is conditional. Terraform Core doesn't share this concept,
|
||||
// required-ness is conditional. OpenTofu Core doesn't share this concept,
|
||||
// so we must sniff for this possibility here and conditionally turn
|
||||
// off the "Required" flag if it looks like the DefaultFunc is going
|
||||
// to provide a value.
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package schema is a legacy package that used to represent the SDK, which is now its own
|
||||
// library external to Terraform Core https://github.com/hashicorp/terraform-plugin-sdk
|
||||
// library external to OpenTofu Core https://github.com/hashicorp/terraform-plugin-sdk
|
||||
// Some of it is still used by Terraform's remote state backends, but this entire
|
||||
// package should be removed in the future.
|
||||
package schema
|
||||
|
@ -14,11 +14,11 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/legacy/tofu"
|
||||
)
|
||||
|
||||
// Provisioner represents a resource provisioner in Terraform and properly
|
||||
// Provisioner represents a resource provisioner in OpenTofu and properly
|
||||
// implements all of the ResourceProvisioner API.
|
||||
//
|
||||
// This higher level structure makes it much easier to implement a new or
|
||||
// custom provisioner for Terraform.
|
||||
// custom provisioner for OpenTofu.
|
||||
//
|
||||
// The function callbacks for this structure are all passed a context object.
|
||||
// This context object has a number of pre-defined values that can be accessed
|
||||
@ -66,7 +66,7 @@ var (
|
||||
// Guaranteed to never be nil.
|
||||
ProvConfigDataKey = contextKey("provider config data")
|
||||
|
||||
// This returns a terraform.UIOutput. Guaranteed to never be nil.
|
||||
// This returns a tofu.UIOutput. Guaranteed to never be nil.
|
||||
ProvOutputKey = contextKey("provider output")
|
||||
|
||||
// This returns the raw InstanceState passed to Apply. Guaranteed to
|
||||
@ -138,7 +138,7 @@ func (p *Provisioner) Apply(
|
||||
|
||||
{
|
||||
// We first need to turn the connection information into a
|
||||
// terraform.ResourceConfig so that we can use that type to more
|
||||
// tofu.ResourceConfig so that we can use that type to more
|
||||
// easily build a ResourceData structure. We do this by simply treating
|
||||
// the conn info as configuration input.
|
||||
raw := make(map[string]interface{})
|
||||
|
@ -32,14 +32,14 @@ var ReservedResourceFields = []string{
|
||||
"provisioner",
|
||||
}
|
||||
|
||||
// Resource represents a thing in Terraform that has a set of configurable
|
||||
// Resource represents a thing in OpenTofu that has a set of configurable
|
||||
// attributes and a lifecycle (create, read, update, delete).
|
||||
//
|
||||
// The Resource schema is an abstraction that allows provider writers to
|
||||
// worry only about CRUD operations while off-loading validation, diff
|
||||
// generation, etc. to this higher level library.
|
||||
//
|
||||
// In spite of the name, this struct is not used only for terraform resources,
|
||||
// In spite of the name, this struct is not used only for tofu resources,
|
||||
// but also for data sources. In the case of data sources, the Create,
|
||||
// Update and Delete functions must not be provided.
|
||||
type Resource struct {
|
||||
@ -86,7 +86,7 @@ type Resource struct {
|
||||
|
||||
// StateUpgraders contains the functions responsible for upgrading an
|
||||
// existing state with an old schema version to a newer schema. It is
|
||||
// called specifically by Terraform when the stored schema version is less
|
||||
// called specifically by OpenTofu when the stored schema version is less
|
||||
// than the current SchemaVersion of the Resource.
|
||||
//
|
||||
// StateUpgraders map specific schema versions to a StateUpgrader
|
||||
@ -127,14 +127,14 @@ type Resource struct {
|
||||
Exists ExistsFunc
|
||||
|
||||
// CustomizeDiff is a custom function for working with the diff that
|
||||
// Terraform has created for this resource - it can be used to customize the
|
||||
// OpenTofu has created for this resource - it can be used to customize the
|
||||
// diff that has been created, diff values not controlled by configuration,
|
||||
// or even veto the diff altogether and abort the plan. It is passed a
|
||||
// *ResourceDiff, a structure similar to ResourceData but lacking most write
|
||||
// functions like Set, while introducing new functions that work with the
|
||||
// diff such as SetNew, SetNewComputed, and ForceNew.
|
||||
//
|
||||
// The phases Terraform runs this in, and the state available via functions
|
||||
// The phases OpenTofu runs this in, and the state available via functions
|
||||
// like Get and GetChange, are as follows:
|
||||
//
|
||||
// * New resource: One run with no state
|
||||
@ -273,7 +273,7 @@ func (r *Resource) Apply(
|
||||
data.timeouts = &rt
|
||||
|
||||
if s == nil {
|
||||
// The Terraform API dictates that this should never happen, but
|
||||
// The OpenTofu API dictates that this should never happen, but
|
||||
// it doesn't hurt to be safe in this case.
|
||||
s = new(tofu.InstanceState)
|
||||
}
|
||||
|
@ -3,25 +3,25 @@
|
||||
|
||||
package schema
|
||||
|
||||
// ResourceImporter defines how a resource is imported in Terraform. This
|
||||
// ResourceImporter defines how a resource is imported in OpenTofu. This
|
||||
// can be set onto a Resource struct to make it Importable. Not all resources
|
||||
// have to be importable; if a Resource doesn't have a ResourceImporter then
|
||||
// it won't be importable.
|
||||
//
|
||||
// "Importing" in Terraform is the process of taking an already-created
|
||||
// resource and bringing it under Terraform management. This can include
|
||||
// updating Terraform state, generating Terraform configuration, etc.
|
||||
// "Importing" in OpenTofu is the process of taking an already-created
|
||||
// resource and bringing it under OpenTofu management. This can include
|
||||
// updating OpenTofu state, generating OpenTofu configuration, etc.
|
||||
type ResourceImporter struct {
|
||||
// The functions below must all be implemented for importing to work.
|
||||
|
||||
// State is called to convert an ID to one or more InstanceState to
|
||||
// insert into the Terraform state. If this isn't specified, then
|
||||
// insert into the OpenTofu state. If this isn't specified, then
|
||||
// the ID is passed straight through.
|
||||
State StateFunc
|
||||
}
|
||||
|
||||
// StateFunc is the function called to import a resource into the
|
||||
// Terraform state. It is given a ResourceData with only ID set. This
|
||||
// OpenTofu state. It is given a ResourceData with only ID set. This
|
||||
// ID is going to be an arbitrary value given by the user and may not map
|
||||
// directly to the ID format that the resource expects, so that should
|
||||
// be validated.
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
// ResourceProvisioner is an interface that must be implemented by any
|
||||
// resource provisioner: the thing that initializes resources in
|
||||
// a Terraform configuration.
|
||||
// a OpenTofu configuration.
|
||||
type ResourceProvisioner interface {
|
||||
// GetConfigSchema returns the schema for the provisioner type's main
|
||||
// configuration block. This is called prior to Validate to enable some
|
||||
@ -38,15 +38,15 @@ type ResourceProvisioner interface {
|
||||
|
||||
// Stop is called when the provisioner should halt any in-flight actions.
|
||||
//
|
||||
// This can be used to make a nicer Ctrl-C experience for Terraform.
|
||||
// This can be used to make a nicer Ctrl-C experience for OpenTofu.
|
||||
// Even if this isn't implemented to do anything (just returns nil),
|
||||
// Terraform will still cleanly stop after the currently executing
|
||||
// OpenTofu will still cleanly stop after the currently executing
|
||||
// graph node is complete. However, this API can be used to make more
|
||||
// efficient halts.
|
||||
//
|
||||
// Stop doesn't have to and shouldn't block waiting for in-flight actions
|
||||
// to complete. It should take any action it wants and return immediately
|
||||
// acknowledging it has received the stop request. Terraform core will
|
||||
// acknowledging it has received the stop request. OpenTofu core will
|
||||
// automatically not make any further API calls to the provider soon
|
||||
// after Stop is called (technically exactly once the currently executing
|
||||
// graph nodes are complete).
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/tfdiags"
|
||||
)
|
||||
|
||||
// Schemas is a container for various kinds of schema that Terraform needs
|
||||
// Schemas is a container for various kinds of schema that OpenTofu needs
|
||||
// during processing.
|
||||
type Schemas struct {
|
||||
Providers map[addrs.Provider]*ProviderSchema
|
||||
|
@ -48,7 +48,7 @@ var rootModulePath = []string{"root"}
|
||||
// have a redundant "root" label at the start of it) into an
|
||||
// addrs.ModuleInstance representing the same module.
|
||||
//
|
||||
// For legacy reasons, different parts of Terraform disagree about whether the
|
||||
// For legacy reasons, different parts of OpenTofu disagree about whether the
|
||||
// root module has the path []string{} or []string{"root"}, and so this
|
||||
// function accepts both and trims off the "root". An implication of this is
|
||||
// that it's not possible to actually have a module call in the root module
|
||||
@ -78,14 +78,14 @@ func normalizeModulePath(p []string) addrs.ModuleInstance {
|
||||
return ret
|
||||
}
|
||||
|
||||
// State keeps track of a snapshot state-of-the-world that Terraform
|
||||
// State keeps track of a snapshot state-of-the-world that OpenTofu
|
||||
// can use to keep track of what real world resources it is actually
|
||||
// managing.
|
||||
type State struct {
|
||||
// Version is the state file protocol version.
|
||||
Version int `json:"version"`
|
||||
|
||||
// TFVersion is the version of Terraform that wrote this state.
|
||||
// TFVersion is the version of OpenTofu that wrote this state.
|
||||
TFVersion string `json:"terraform_version,omitempty"`
|
||||
|
||||
// Serial is incremented on any operation that modifies
|
||||
@ -188,7 +188,7 @@ func (s *State) addModule(path addrs.ModuleInstance) *ModuleState {
|
||||
legacyPath[0] = "root"
|
||||
for i, step := range path {
|
||||
if step.InstanceKey != addrs.NoKey {
|
||||
// FIXME: Once the rest of Terraform is ready to use count and
|
||||
// FIXME: Once the rest of OpenTofu is ready to use count and
|
||||
// for_each, remove all of this and just write the addrs.ModuleInstance
|
||||
// value itself into the ModuleState.
|
||||
panic("state cannot represent modules with count or for_each keys")
|
||||
@ -283,8 +283,8 @@ func (s *State) IsRemote() bool {
|
||||
|
||||
// Validate validates the integrity of this state file.
|
||||
//
|
||||
// Certain properties of the statefile are expected by Terraform in order
|
||||
// to behave properly. The core of Terraform will assume that once it
|
||||
// Certain properties of the statefile are expected by OpenTofu in order
|
||||
// to behave properly. The core of OpenTofu will assume that once it
|
||||
// receives a State structure that it has been validated. This validation
|
||||
// check should be called to ensure that.
|
||||
//
|
||||
@ -547,7 +547,7 @@ const (
|
||||
//
|
||||
// This is a simple check using the state's serial, and is thus only as
|
||||
// reliable as the serial itself. In the normal case, only one state
|
||||
// exists for a given combination of lineage/serial, but Terraform
|
||||
// exists for a given combination of lineage/serial, but OpenTofu
|
||||
// does not guarantee this and so the result of this method should be
|
||||
// used with care.
|
||||
//
|
||||
@ -617,7 +617,7 @@ func (s *State) DeepCopy() *State {
|
||||
return copy.(*State)
|
||||
}
|
||||
|
||||
// FromFutureTerraform checks if this state was written by a Terraform
|
||||
// FromFutureTerraform checks if this state was written by a OpenTofu
|
||||
// version from the future.
|
||||
func (s *State) FromFutureTerraform() bool {
|
||||
s.Lock()
|
||||
@ -986,12 +986,12 @@ type ModuleState struct {
|
||||
// existing to remain intact. For example: an module may depend
|
||||
// on a VPC ID given by an aws_vpc resource.
|
||||
//
|
||||
// Terraform uses this information to build valid destruction
|
||||
// OpenTofu uses this information to build valid destruction
|
||||
// orders and to warn the user if they're destroying a module that
|
||||
// another resource depends on.
|
||||
//
|
||||
// Things can be put into this list that may not be managed by
|
||||
// Terraform. If Terraform doesn't find a matching ID in the
|
||||
// OpenTofu. If OpenTofu doesn't find a matching ID in the
|
||||
// overall state, then it assumes it isn't managed and doesn't
|
||||
// worry about it.
|
||||
Dependencies []string `json:"depends_on"`
|
||||
@ -1428,7 +1428,7 @@ func ParseResourceStateKey(k string) (*ResourceStateKey, error) {
|
||||
// Extra is just extra data that a provider can return that we store
|
||||
// for later, but is not exposed in any way to the user.
|
||||
type ResourceState struct {
|
||||
// This is filled in and managed by Terraform, and is the resource
|
||||
// This is filled in and managed by OpenTofu, and is the resource
|
||||
// type itself such as "mycloud_instance". If a resource provider sets
|
||||
// this value, it won't be persisted.
|
||||
Type string `json:"type"`
|
||||
@ -1438,12 +1438,12 @@ type ResourceState struct {
|
||||
// depend on a subnet (which itself might depend on a VPC, and so
|
||||
// on).
|
||||
//
|
||||
// Terraform uses this information to build valid destruction
|
||||
// OpenTofu uses this information to build valid destruction
|
||||
// orders and to warn the user if they're destroying a resource that
|
||||
// another resource depends on.
|
||||
//
|
||||
// Things can be put into this list that may not be managed by
|
||||
// Terraform. If Terraform doesn't find a matching ID in the
|
||||
// OpenTofu. If OpenTofu doesn't find a matching ID in the
|
||||
// overall state, then it assumes it isn't managed and doesn't
|
||||
// worry about it.
|
||||
Dependencies []string `json:"depends_on"`
|
||||
@ -1615,22 +1615,22 @@ func (s *ResourceState) String() string {
|
||||
// InstanceState is used to track the unique state information belonging
|
||||
// to a given instance.
|
||||
type InstanceState struct {
|
||||
// A unique ID for this resource. This is opaque to Terraform
|
||||
// A unique ID for this resource. This is opaque to OpenTofu
|
||||
// and is only meant as a lookup mechanism for the providers.
|
||||
ID string `json:"id"`
|
||||
|
||||
// Attributes are basic information about the resource. Any keys here
|
||||
// are accessible in variable format within Terraform configurations:
|
||||
// are accessible in variable format within OpenTofu configurations:
|
||||
// ${resourcetype.name.attribute}.
|
||||
Attributes map[string]string `json:"attributes"`
|
||||
|
||||
// Ephemeral is used to store any state associated with this instance
|
||||
// that is necessary for the Terraform run to complete, but is not
|
||||
// that is necessary for the OpenTofu run to complete, but is not
|
||||
// persisted to a state file.
|
||||
Ephemeral EphemeralState `json:"-"`
|
||||
|
||||
// Meta is a simple K/V map that is persisted to the State but otherwise
|
||||
// ignored by Terraform core. It's meant to be used for accounting by
|
||||
// ignored by OpenTofu core. It's meant to be used for accounting by
|
||||
// external client code. The value here must only contain Go primitives
|
||||
// and collections.
|
||||
Meta map[string]interface{} `json:"meta"`
|
||||
|
@ -34,7 +34,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// ValidLevels are the log level names that Terraform recognizes.
|
||||
// ValidLevels are the log level names that OpenTofu recognizes.
|
||||
ValidLevels = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"}
|
||||
|
||||
// logger is the global hclog logger
|
||||
|
@ -33,14 +33,14 @@ shown below, and any additional information which may help replicate the issue.
|
||||
// recovered by PanicHandler starts printing.
|
||||
var panicMutex sync.Mutex
|
||||
|
||||
// PanicHandler is called to recover from an internal panic in Terraform, and
|
||||
// PanicHandler is called to recover from an internal panic in OpenTofu, and
|
||||
// augments the standard stack trace with a more user friendly error message.
|
||||
// PanicHandler must be called as a defered function, and must be the first
|
||||
// defer called at the start of a new goroutine.
|
||||
func PanicHandler() {
|
||||
// Have all managed goroutines checkin here, and prevent them from exiting
|
||||
// if there's a panic in progress. While this can't lock the entire runtime
|
||||
// to block progress, we can prevent some cases where Terraform may return
|
||||
// to block progress, we can prevent some cases where OpenTofu may return
|
||||
// early before the panic has been printed out.
|
||||
panicMutex.Lock()
|
||||
defer panicMutex.Unlock()
|
||||
|
@ -98,7 +98,7 @@ func ReadManifestSnapshot(r io.Reader) (Manifest, error) {
|
||||
// Historically we didn't normalize the module source addresses when
|
||||
// writing them into the manifest, and so we'll make a best effort
|
||||
// to normalize them back in on read so that we can just gracefully
|
||||
// upgrade on the next "terraform init".
|
||||
// upgrade on the next "tofu init".
|
||||
if record.SourceAddr != "" {
|
||||
if addr, err := addrs.ParseModuleSource(record.SourceAddr); err == nil {
|
||||
// This is a best effort sort of thing. If the source
|
||||
@ -116,7 +116,7 @@ func ReadManifestSnapshot(r io.Reader) (Manifest, error) {
|
||||
if _, exists := new[record.Key]; exists {
|
||||
// This should never happen in any valid file, so we'll catch it
|
||||
// and report it to avoid confusing/undefined behavior if the
|
||||
// snapshot file was edited incorrectly outside of Terraform.
|
||||
// snapshot file was edited incorrectly outside of OpenTofu.
|
||||
return nil, fmt.Errorf("snapshot file contains two records for path %s", record.Key)
|
||||
}
|
||||
new[record.Key] = record
|
||||
|
@ -5,6 +5,6 @@
|
||||
// providers required for all of the modules in a module tree.
|
||||
//
|
||||
// It does not itself contain the functionality for populating such
|
||||
// data structures; that's in Terraform core, since this package intentionally
|
||||
// does not depend on terraform core to avoid package dependency cycles.
|
||||
// data structures; that's in OpenTofu core, since this package intentionally
|
||||
// does not depend on OpenTofu core to avoid package dependency cycles.
|
||||
package moduledeps
|
||||
|
@ -112,17 +112,17 @@ func (run *Run) GetReferences() ([]*addrs.Reference, tfdiags.Diagnostics) {
|
||||
// test will fail later.
|
||||
// 3. Adds diagnostics for any expected failures that were not satisfied.
|
||||
//
|
||||
// Point 2 is a bit complicated so worth expanding on. In normal Terraform
|
||||
// Point 2 is a bit complicated so worth expanding on. In normal OpenTofu
|
||||
// execution, any error that originates within a check block (either from an
|
||||
// assertion or a scoped data source) is wrapped up as a Warning to be
|
||||
// identified to the user but not to fail the actual Terraform operation. During
|
||||
// identified to the user but not to fail the actual OpenTofu operation. During
|
||||
// test execution, we want to upgrade (or rollback) these warnings into errors
|
||||
// again so the test will fail. We do that as part of this function as we are
|
||||
// already processing the diagnostics from check blocks in here anyway.
|
||||
//
|
||||
// The way the function works out which diagnostics are relevant to expected
|
||||
// failures is by using the tfdiags Extra functionality to detect which
|
||||
// diagnostics were generated by custom conditions. Terraform adds the
|
||||
// diagnostics were generated by custom conditions. OpenTofu adds the
|
||||
// addrs.CheckRule that generated each diagnostic to the diagnostic itself so we
|
||||
// can tell which diagnostics can be expected.
|
||||
func (run *Run) ValidateExpectedFailures(originals tfdiags.Diagnostics) tfdiags.Diagnostics {
|
||||
|
@ -269,7 +269,7 @@ func resourceChangeFromTfplan(rawChange *planproto.ResourceInstanceChange) (*pla
|
||||
|
||||
if rawChange.Addr == "" {
|
||||
// If "Addr" isn't populated then seems likely that this is a plan
|
||||
// file created by an earlier version of Terraform, which had the
|
||||
// file created by an earlier version of OpenTofu, which had the
|
||||
// same information spread over various other fields:
|
||||
// ModulePath, Mode, Name, Type, and InstanceKey.
|
||||
return nil, fmt.Errorf("no instance address for resource instance change; perhaps this plan was created by a different version of OpenTofu or a different version of Terraform?")
|
||||
|
@ -97,7 +97,7 @@ func ProtoToProviderSchema(s *proto.Schema) providers.Schema {
|
||||
}
|
||||
|
||||
// ProtoToConfigSchema takes the GetSchcema_Block from a grpc response and converts it
|
||||
// to a terraform *configschema.Block.
|
||||
// to a tofu *configschema.Block.
|
||||
func ProtoToConfigSchema(b *proto.Schema_Block) *configschema.Block {
|
||||
block := &configschema.Block{
|
||||
Attributes: make(map[string]*configschema.Attribute),
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/tofu"
|
||||
)
|
||||
|
||||
// UIInput is an implementation of terraform.UIInput that communicates
|
||||
// UIInput is an implementation of tofu.UIInput that communicates
|
||||
// over RPC.
|
||||
type UIInput struct {
|
||||
Client *rpc.Client
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/tofu"
|
||||
)
|
||||
|
||||
// UIOutput is an implementatin of terraform.UIOutput that communicates
|
||||
// UIOutput is an implementatin of tofu.UIOutput that communicates
|
||||
// over RPC.
|
||||
type UIOutput struct {
|
||||
Client *rpc.Client
|
||||
|
@ -103,7 +103,7 @@ func ProtoToProviderSchema(s *proto.Schema) providers.Schema {
|
||||
}
|
||||
|
||||
// ProtoToConfigSchema takes the GetSchcema_Block from a grpc response and converts it
|
||||
// to a terraform *configschema.Block.
|
||||
// to a tofu *configschema.Block.
|
||||
func ProtoToConfigSchema(b *proto.Schema_Block) *configschema.Block {
|
||||
block := &configschema.Block{
|
||||
Attributes: make(map[string]*configschema.Attribute),
|
||||
|
@ -48,12 +48,12 @@ type Installer struct {
|
||||
|
||||
// builtInProviderTypes is an optional set of types that should be
|
||||
// considered valid to appear in the special terraform.io/builtin/...
|
||||
// namespace, which we use for providers that are built in to Terraform
|
||||
// namespace, which we use for providers that are built in to OpenTofu
|
||||
// and thus do not need any separate installation step.
|
||||
builtInProviderTypes []string
|
||||
|
||||
// unmanagedProviderTypes is a set of provider addresses that should be
|
||||
// considered implemented, but that Terraform does not manage the
|
||||
// considered implemented, but that OpenTofu does not manage the
|
||||
// lifecycle for, and therefore does not need to worry about the
|
||||
// installation of.
|
||||
unmanagedProviderTypes map[addrs.Provider]struct{}
|
||||
@ -121,7 +121,7 @@ func (i *Installer) SetGlobalCacheDir(cacheDir *Dir) {
|
||||
// If this is set then if we install a provider for the first time from the
|
||||
// cache then the dependency lock file will include only the checksum from
|
||||
// the package in the global cache, which means the lock file won't be portable
|
||||
// to Terraform running on another operating system or CPU architecture.
|
||||
// to OpenTofu running on another operating system or CPU architecture.
|
||||
func (i *Installer) SetGlobalCacheDirMayBreakDependencyLockFile(mayBreak bool) {
|
||||
i.globalCacheDirMayBreakDependencyLockFile = mayBreak
|
||||
}
|
||||
@ -135,7 +135,7 @@ func (i *Installer) HasGlobalCacheDir() bool {
|
||||
// SetBuiltInProviderTypes tells the receiver to consider the type names in the
|
||||
// given slice to be valid as providers in the special special
|
||||
// terraform.io/builtin/... namespace that we use for providers that are
|
||||
// built in to Terraform and thus do not need a separate installation step.
|
||||
// built in to OpenTofu and thus do not need a separate installation step.
|
||||
//
|
||||
// If a caller requests installation of a provider in that namespace, the
|
||||
// installer will treat it as a no-op if its name exists in this list, but
|
||||
@ -151,10 +151,10 @@ func (i *Installer) SetBuiltInProviderTypes(types []string) {
|
||||
}
|
||||
|
||||
// SetUnmanagedProviderTypes tells the receiver to consider the providers
|
||||
// indicated by the passed addrs.Providers as unmanaged. Terraform does not
|
||||
// indicated by the passed addrs.Providers as unmanaged. OpenTofu does not
|
||||
// need to control the lifecycle of these providers, and they are assumed to be
|
||||
// running already when Terraform is started. Because these are essentially
|
||||
// processes, not binaries, Terraform will not do any work to ensure presence
|
||||
// running already when OpenTofu is started. Because these are essentially
|
||||
// processes, not binaries, OpenTofu will not do any work to ensure presence
|
||||
// or versioning of these binaries.
|
||||
func (i *Installer) SetUnmanagedProviderTypes(types map[addrs.Provider]struct{}) {
|
||||
i.unmanagedProviderTypes = types
|
||||
@ -224,7 +224,7 @@ func (i *Installer) EnsureProviderVersions(ctx context.Context, locks *depsfile.
|
||||
} else {
|
||||
// A built-in provider is not permitted to have an explicit
|
||||
// version constraint, because we can only use the version
|
||||
// that is built in to the current Terraform release.
|
||||
// that is built in to the current OpenTofu release.
|
||||
err = fmt.Errorf("built-in providers do not support explicit version constraints")
|
||||
}
|
||||
} else {
|
||||
|
@ -44,13 +44,13 @@ type InstallerEvents struct {
|
||||
ProviderAlreadyInstalled func(provider addrs.Provider, selectedVersion getproviders.Version)
|
||||
|
||||
// The BuiltInProvider... family of events describe the outcome for any
|
||||
// requested providers that are built in to Terraform. Only one of these
|
||||
// requested providers that are built in to OpenTofu. Only one of these
|
||||
// methods will be called for each such provider, and no other method
|
||||
// will be called for them except that they are included in the
|
||||
// aggregate PendingProviders map.
|
||||
//
|
||||
// The "Available" event reports that the requested builtin provider is
|
||||
// available in this release of Terraform. The "Failure" event reports
|
||||
// available in this release of OpenTofu. The "Failure" event reports
|
||||
// either that the provider is unavailable or that the request for it
|
||||
// is invalid somehow.
|
||||
BuiltInProviderAvailable func(provider addrs.Provider)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user