Merge branch 'main' of github.com:opentffoundation/opentf into chore-rename-terraform-to-opentf-in-docs

This commit is contained in:
Yaron Yarimi 2023-08-22 16:22:24 +03:00
commit 67e9d1f2e4
36 changed files with 236 additions and 236 deletions

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: MPL-2.0
// Package backend provides interfaces that the CLI uses to interact with
// Terraform. A backend provides the abstraction that allows the same CLI
// OpenTF. A backend provides the abstraction that allows the same CLI
// to simultaneously support both local and remote operations for seamlessly
// using Terraform in a team environment.
// using OpenTF in a team environment.
package backend
import (
@ -55,7 +55,7 @@ var (
// InitFn is used to initialize a new backend.
type InitFn func() Backend
// Backend is the minimal interface that must be implemented to enable Terraform.
// Backend is the minimal interface that must be implemented to enable OpenTF.
type Backend interface {
// ConfigSchema returns a description of the expected configuration
// structure for the receiving backend.
@ -136,7 +136,7 @@ type HostAlias struct {
type Enhanced interface {
Backend
// Operation performs a Terraform operation such as refresh, plan, apply.
// Operation performs a OpenTF operation such as refresh, plan, apply.
// It is up to the implementation to determine what "performing" means.
// This DOES NOT BLOCK. The context returned as part of RunningOperation
// should be used to block for completion.
@ -153,7 +153,7 @@ type Enhanced interface {
// Local implements additional behavior on a Backend that allows local
// operations in addition to remote operations.
//
// This enables more behaviors of Terraform that require more data such
// This enables more behaviors of OpenTF that require more data such
// as `console`, `import`, `graph`. These require direct access to
// configurations, variables, and more. Not all backends may support this
// so we separate it out into its own optional interface.
@ -183,12 +183,12 @@ type Local interface {
//
// This type is a weird architectural wart resulting from the overly-general
// way our backend API models operations, whereby we behave as if all
// Terraform operations have the same inputs and outputs even though they
// OpenTF operations have the same inputs and outputs even though they
// are actually all rather different. The exact meaning of the fields in
// this type therefore vary depending on which OperationType was passed to
// Local.Context in order to create an object of this type.
type LocalRun struct {
// Core is an already-initialized Terraform Core context, ready to be
// Core is an already-initialized OpenTF Core context, ready to be
// used to run operations such as Plan and Apply.
Core *terraform.Context
@ -217,7 +217,7 @@ type LocalRun struct {
Plan *plans.Plan
}
// An operation represents an operation for Terraform to execute.
// An operation represents an operation for OpenTF to execute.
//
// Note that not all fields are supported by all backends and can result
// in an error if set. All backend implementations should show user-friendly
@ -225,12 +225,12 @@ type LocalRun struct {
// backend doesn't support a PlanId being set.
//
// The operation options are purposely designed to have maximal compatibility
// between Terraform and Terraform Servers (a commercial product offered by
// between OpenTF and Terraform Servers (a commercial product offered by
// HashiCorp). Therefore, it isn't expected that other implementation support
// every possible option. The struct here is generalized in order to allow
// even partial implementations to exist in the open, without walling off
// remote functionality 100% behind a commercial wall. Anyone can implement
// against this interface and have Terraform interact with it just as it
// against this interface and have OpenTF interact with it just as it
// would with HashiCorp-provided Terraform Servers.
type Operation struct {
// Type is the operation to perform.
@ -315,7 +315,7 @@ type Operation struct {
}
// HasConfig returns true if and only if the operation has a ConfigDir value
// that refers to a directory containing at least one Terraform configuration
// that refers to a directory containing at least one OpenTF configuration
// file.
func (o *Operation) HasConfig() bool {
return o.ConfigLoader.IsConfigDir(o.ConfigDir)

View File

@ -60,7 +60,7 @@ func TestReadPathOrContents_TildePath(t *testing.T) {
func TestRead_PathNoPermission(t *testing.T) {
// This skip condition is intended to get this test out of the way of users
// who are building and testing Terraform from within a Linux-based Docker
// who are building and testing OpenTF from within a Linux-based Docker
// container, where it is common for processes to be running as effectively
// root within the container.
if u, err := user.Current(); err == nil && u.Uid == "0" {

View File

@ -12,12 +12,12 @@ import (
)
// CLI is an optional interface that can be implemented to be initialized
// with information from the Terraform CLI. If this is implemented, this
// with information from the OpenTF CLI. If this is implemented, this
// initialization function will be called with data to help interact better
// with a CLI.
//
// This interface was created to improve backend interaction with the
// official Terraform CLI while making it optional for API users to have
// official OpenTF CLI while making it optional for API users to have
// to provide full CLI interaction to every backend.
//
// If you're implementing a Backend, it is acceptable to require CLI
@ -71,7 +71,7 @@ type CLIOpts struct {
StateBackupPath string
// ContextOpts are the base context options to set when initializing a
// Terraform context. Many of these will be overridden or merged by
// OpenTF context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *terraform.ContextOpts
@ -87,7 +87,7 @@ type CLIOpts struct {
// automated system rather than directly at a command prompt.
//
// This is a hint not to produce messages that expect that a user can
// run a follow-up command, perhaps because Terraform is running in
// run a follow-up command, perhaps because OpenTF is running in
// some sort of workflow automation tool that abstracts away the
// exact commands that are being run.
RunningInAutomation bool

View File

@ -29,13 +29,13 @@ import (
)
// backends is the list of available backends. This is a global variable
// because backends are currently hardcoded into Terraform and can't be
// because backends are currently hardcoded into OpenTF and can't be
// modified without recompilation.
//
// To read an available backend, use the Backend function. This ensures
// safe concurrent read access to the list of built-in backends.
//
// Backends are hardcoded into Terraform because the API for backends uses
// Backends are hardcoded into OpenTF because the API for backends uses
// complex structures and supporting that over the plugin system is currently
// prohibitively difficult. For those wanting to implement a custom backend,
// they can do so with recompilation.
@ -73,12 +73,12 @@ func Init(services *disco.Disco) {
}
RemovedBackends = map[string]string{
"artifactory": `The "artifactory" backend is not supported in Terraform v1.3 or later.`,
"artifactory": `The "artifactory" backend is not supported in OpenTF v1.3 or later.`,
"azure": `The "azure" backend name has been removed, please use "azurerm".`,
"etcd": `The "etcd" backend is not supported in Terraform v1.3 or later.`,
"etcdv3": `The "etcdv3" backend is not supported in Terraform v1.3 or later.`,
"manta": `The "manta" backend is not supported in Terraform v1.3 or later.`,
"swift": `The "swift" backend is not supported in Terraform v1.3 or later.`,
"etcd": `The "etcd" backend is not supported in OpenTF v1.3 or later.`,
"etcdv3": `The "etcdv3" backend is not supported in OpenTF v1.3 or later.`,
"manta": `The "manta" backend is not supported in OpenTF v1.3 or later.`,
"swift": `The "swift" backend is not supported in OpenTF v1.3 or later.`,
}
}
@ -95,7 +95,7 @@ func Backend(name string) backend.InitFn {
// then it will be overwritten.
//
// This method sets this backend globally and care should be taken to do
// this only before Terraform is executing to prevent odd behavior of backends
// this only before OpenTF is executing to prevent odd behavior of backends
// changing mid-execution.
func Set(name string, f backend.InitFn) {
backendsLock.Lock()

View File

@ -32,7 +32,7 @@ const (
)
// Local is an implementation of EnhancedBackend that performs all operations
// locally. This is the "default" backend and implements normal Terraform
// locally. This is the "default" backend and implements normal OpenTF
// behavior as it is well known.
type Local struct {
// The State* paths are set from the backend config, and may be left blank
@ -66,7 +66,7 @@ type Local struct {
// here as they're loaded.
states map[string]statemgr.Full
// Terraform context. Many of these will be overridden or merged by
// OpenTF context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *terraform.ContextOpts
@ -293,8 +293,8 @@ func (b *Local) Operation(ctx context.Context, op *backend.Operation) (*backend.
default:
return nil, fmt.Errorf(
"unsupported operation type: %s\n\n"+
"This is a bug in Terraform and should be reported. The local backend\n"+
"is built-in to Terraform and should always support all operations.",
"This is a bug in OpenTF and should be reported. The local backend\n"+
"is built-in to OpenTF and should always support all operations.",
op.Type)
}
@ -493,4 +493,4 @@ func (b *Local) stateWorkspaceDir() string {
const earlyStateWriteErrorFmt = `Error: %s
Terraform encountered an error attempting to save the state before cancelling the current operation. Once the operation is complete another attempt will be made to save the final state.`
OpenTF encountered an error attempting to save the state before cancelling the current operation. Once the operation is complete another attempt will be made to save the final state.`

View File

@ -42,7 +42,7 @@ func (b *Local) opApply(
"No configuration files",
"Apply requires configuration to be present. Applying without a configuration "+
"would mark everything for destruction, which is normally not what is desired. "+
"If you would like to destroy everything, run 'terraform destroy' instead.",
"If you would like to destroy everything, run 'opentf destroy' instead.",
))
op.ReportResult(runningOp, diags)
return
@ -92,10 +92,10 @@ func (b *Local) opApply(
plan, moreDiags = lr.Core.Plan(lr.Config, lr.InputState, lr.PlanOpts)
diags = diags.Append(moreDiags)
if moreDiags.HasErrors() {
// If Terraform Core generated a partial plan despite the errors
// then we'll make a best effort to render it. Terraform Core
// If OpenTF Core generated a partial plan despite the errors
// then we'll make the best effort to render it. OpenTF Core
// promises that if it returns a non-nil plan along with errors
// then the plan won't necessarily contain all of the needed
// then the plan won't necessarily contain all the needed
// actions but that any it does include will be properly-formed.
// plan.Errored will be true in this case, which our plan
// renderer can rely on to tailor its messaging.
@ -136,15 +136,15 @@ func (b *Local) opApply(
} else {
query = "Do you really want to destroy all resources?"
}
desc = "Terraform will destroy all your managed infrastructure, as shown above.\n" +
desc = "OpenTF will destroy all your managed infrastructure, as shown above.\n" +
"There is no undo. Only 'yes' will be accepted to confirm."
case plans.RefreshOnlyMode:
if op.Workspace != "default" {
query = "Would you like to update the Terraform state for \"" + op.Workspace + "\" to reflect these detected changes?"
query = "Would you like to update the OpenTF state for \"" + op.Workspace + "\" to reflect these detected changes?"
} else {
query = "Would you like to update the Terraform state to reflect these detected changes?"
query = "Would you like to update the OpenTF state to reflect these detected changes?"
}
desc = "Terraform will write these changes to the state without modifying any real infrastructure.\n" +
desc = "OpenTF will write these changes to the state without modifying any real infrastructure.\n" +
"There is no undo. Only 'yes' will be accepted to confirm."
default:
if op.Workspace != "default" {
@ -152,7 +152,7 @@ func (b *Local) opApply(
} else {
query = "Do you want to perform these actions?"
}
desc = "Terraform will perform the actions described above.\n" +
desc = "OpenTF will perform the actions described above.\n" +
"Only 'yes' will be accepted to approve."
}
@ -212,7 +212,7 @@ func (b *Local) opApply(
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Cannot apply incomplete plan",
"Terraform encountered an error when generating this plan, so it cannot be applied.",
"OpenTF encountered an error when generating this plan, so it cannot be applied.",
))
op.ReportResult(runningOp, diags)
return
@ -227,7 +227,7 @@ func (b *Local) opApply(
// Set up our hook for continuous state updates
stateHook.StateMgr = opState
// Start the apply in a goroutine so that we can be interrupted.
// Start to apply in a goroutine so that we can be interrupted.
var applyState *states.State
var applyDiags tfdiags.Diagnostics
doneCh := make(chan struct{})
@ -332,29 +332,29 @@ func (b *Local) backupStateForError(stateFile *statefile.File, err error, view v
return diags
}
const stateWriteBackedUpError = `The error shown above has prevented Terraform from writing the updated state to the configured backend. To allow for recovery, the state has been written to the file "errored.tfstate" in the current working directory.
const stateWriteBackedUpError = `The error shown above has prevented OpenTF from writing the updated state to the configured backend. To allow for recovery, the state has been written to the file "errored.tfstate" in the current working directory.
Running "terraform apply" again at this point will create a forked state, making it harder to recover.
Running "opentf apply" again at this point will create a forked state, making it harder to recover.
To retry writing this state, use the following command:
terraform state push errored.tfstate
opentf state push errored.tfstate
`
const stateWriteConsoleFallbackError = `The errors shown above prevented Terraform from writing the updated state to
const stateWriteConsoleFallbackError = `The errors shown above prevented OpenTF from writing the updated state to
the configured backend and from creating a local backup file. As a fallback,
the raw state data is printed above as a JSON object.
To retry writing this state, copy the state data (from the first { to the last } inclusive) and save it into a local file called errored.tfstate, then run the following command:
terraform state push errored.tfstate
opentf state push errored.tfstate
`
const stateWriteFatalErrorFmt = `Failed to save state after apply.
Error serializing state: %s
A catastrophic error has prevented Terraform from persisting the state file or creating a backup. Unfortunately this means that the record of any resources created during this apply has been lost, and such resources may exist outside of Terraform's management.
A catastrophic error has prevented OpenTF from persisting the state file or creating a backup. Unfortunately this means that the record of any resources created during this apply has been lost, and such resources may exist outside of OpenTF's management.
For resources that support import, it is possible to recover by manually importing each resource using its id from the target system.
This is a serious bug in Terraform and should be reported.
This is a serious bug in OpenTF and should be reported.
`

View File

@ -78,7 +78,7 @@ func (b *Local) localRun(op *backend.Operation) (*backend.LocalRun, *configload.
var ctxDiags tfdiags.Diagnostics
var configSnap *configload.Snapshot
if op.PlanFile.IsCloud() {
diags = diags.Append(fmt.Errorf("error: using a saved cloud plan when executing Terraform locally is not supported"))
diags = diags.Append(fmt.Errorf("error: using a saved cloud plan when executing OpenTF locally is not supported"))
return nil, nil, nil, diags
}
@ -157,11 +157,11 @@ func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, cor
case op.DependencyLocks == nil:
// If we get here then it suggests that there's a caller that we
// didn't yet update to populate DependencyLocks, which is a bug.
suggestion = "This run has no dependency lock information provided at all, which is a bug in Terraform; please report it!"
suggestion = "This run has no dependency lock information provided at all, which is a bug in OpenTF; please report it!"
case op.DependencyLocks.Empty():
suggestion = "To make the initial dependency selections that will initialize the dependency lock file, run:\n terraform init"
suggestion = "To make the initial dependency selections that will initialize the dependency lock file, run:\n opentf init"
default:
suggestion = "To update the locked dependency selections to match a changed configuration, run:\n terraform init -upgrade"
suggestion = "To update the locked dependency selections to match a changed configuration, run:\n opentf init -upgrade"
}
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
@ -362,12 +362,12 @@ func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader,
//
// This function does not modify the map given in "existing", but may return
// it unchanged if no modifications are required. If modifications are required,
// the result is a new map with all of the elements from "existing" plus
// the result is a new map with all the elements from "existing" plus
// additional elements as appropriate.
//
// Interactive prompting is a "best effort" thing for first-time user UX and
// not something we expect folks to be relying on for routine use. Terraform
// is primarily a non-interactive tool and so we prefer to report in error
// not something we expect folks to be relying on for routine use. OpenTF
// is primarily a non-interactive tool, and so we prefer to report in error
// messages that variables are not set rather than reporting that input failed:
// the primary resolution to missing variables is to provide them by some other
// means.
@ -435,8 +435,8 @@ func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[st
//
// This function should be used only in situations where variables values
// will not be directly used and the variables map is being constructed only
// to produce a complete Terraform context for some ancillary functionality
// like "terraform console", "terraform state ...", etc.
// to produce a complete OpenTF context for some ancillary functionality
// like "opentf console", "opentf state ...", etc.
//
// This function is guaranteed not to modify the given map, but it may return
// the given map unchanged if no additions are required. If additions are

View File

@ -49,7 +49,7 @@ func (b *Local) opPlan(
"Plan requires configuration to be present. Planning without a configuration would "+
"mark everything for destruction, which is normally not what is desired. If you "+
"would like to destroy everything, run plan with the -destroy option. Otherwise, "+
"create a Terraform configuration file (.tf file) and try again.",
"create a OpenTF configuration file (.tf file) and try again.",
))
op.ReportResult(runningOp, diags)
return
@ -139,7 +139,7 @@ func (b *Local) opPlan(
// This is always a bug in the operation caller; it's not valid
// to set PlanOutPath without also setting PlanOutBackend.
diags = diags.Append(fmt.Errorf(
"PlanOutPath set without also setting PlanOutBackend (this is a bug in Terraform)"),
"PlanOutPath set without also setting PlanOutBackend (this is a bug in OpenTF)"),
)
op.ReportResult(runningOp, diags)
return
@ -157,7 +157,7 @@ func (b *Local) opPlan(
// there) and so we just use a stub state file header in this case.
// NOTE: This won't be exactly identical to the latest state snapshot
// in the backend because it's still been subject to state upgrading
// to make it consumable by the current Terraform version, and
// to make it consumable by the current OpenTF version, and
// intentionally doesn't preserve the header info.
prevStateFile := &statefile.File{
State: plan.PrevRunState,
@ -204,7 +204,7 @@ func (b *Local) opPlan(
// If we've accumulated any diagnostics along the way then we'll show them
// here just before we show the summary and next steps. This can potentially
// include errors, because we intentionally try to show a partial plan
// above even if Terraform Core encountered an error partway through
// above even if OpenTF Core encountered an error partway through
// creating it.
op.ReportResult(runningOp, diags)

View File

@ -229,8 +229,8 @@ Changes to Outputs:
~ sensitive_after = (sensitive value)
~ sensitive_before = (sensitive value)
You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.
You can apply this plan to save these new output values to the OpenTF state,
without changing any real infrastructure.
`)
if output := done(t).Stdout(); !strings.Contains(output, expectedOutput) {
@ -322,13 +322,13 @@ func TestLocal_planTainted(t *testing.T) {
t.Fatal("plan should not be empty")
}
expectedOutput := `Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
expectedOutput := `OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_instance.foo is tainted, so must be replaced
# test_instance.foo is tainted, so it must be replaced
-/+ resource "test_instance" "foo" {
# (1 unchanged attribute hidden)
@ -403,12 +403,12 @@ func TestLocal_planDeposedOnly(t *testing.T) {
// The deposed object and the current object are distinct, so our
// plan includes separate actions for each of them. This strange situation
// is not common: it should arise only if Terraform fails during
// a create-before-destroy when the create hasn't completed yet but
// is not common: it should arise only if OpenTF fails during
// a create-before-destroy when the "create" hasn't completed yet but
// in a severe way that prevents the previous object from being restored
// as "current".
//
// However, that situation was more common in some earlier Terraform
// However, that situation was more common in some earlier OpenTF
// versions where deposed objects were not managed properly, so this
// can arise when upgrading from an older version with deposed objects
// already in the state.
@ -416,16 +416,16 @@ func TestLocal_planDeposedOnly(t *testing.T) {
// This is one of the few cases where we expose the idea of "deposed" in
// the UI, including the user-unfriendly "deposed key" (00000000 in this
// case) just so that users can correlate this with what they might
// see in `terraform show` and in the subsequent apply output, because
// see in `opentf show` and in the subsequent apply output, because
// it's also possible for there to be _multiple_ deposed objects, in the
// unlikely event that create_before_destroy _keeps_ crashing across
// subsequent runs.
expectedOutput := `Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
expectedOutput := `OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
- destroy
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_instance.foo will be created
+ resource "test_instance" "foo" {
@ -450,7 +450,7 @@ Terraform will perform the following actions:
Plan: 1 to add, 0 to change, 1 to destroy.`
if output := done(t).Stdout(); !strings.Contains(output, expectedOutput) {
t.Fatalf("Unexpected output:\n%s", output)
t.Fatalf("Unexpected output\ngot\n%s\n\nwant:\n%s", output, expectedOutput)
}
}
@ -492,13 +492,13 @@ func TestLocal_planTainted_createBeforeDestroy(t *testing.T) {
t.Fatal("plan should not be empty")
}
expectedOutput := `Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
expectedOutput := `OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+/- create replacement and then destroy
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_instance.foo is tainted, so must be replaced
# test_instance.foo is tainted, so it must be replaced
+/- resource "test_instance" "foo" {
# (1 unchanged attribute hidden)
@ -507,7 +507,7 @@ Terraform will perform the following actions:
Plan: 1 to add, 0 to change, 1 to destroy.`
if output := done(t).Stdout(); !strings.Contains(output, expectedOutput) {
t.Fatalf("Unexpected output:\n%s", output)
t.Fatalf("Unexpected output\ngot\n%s\n\nwant:\n%s", output, expectedOutput)
}
}
@ -642,7 +642,7 @@ func TestLocal_planDestroy_withDataSources(t *testing.T) {
}
// Data source should not be rendered in the output
expectedOutput := `Terraform will perform the following actions:
expectedOutput := `OpenTF will perform the following actions:
# test_instance.foo[0] will be destroyed
- resource "test_instance" "foo" {

View File

@ -46,11 +46,11 @@ type IntermediateStatePersistInfo struct {
RequestedPersistInterval time.Duration
// LastPersist is the time when the last intermediate state snapshot was
// persisted, or the time of the first report for Terraform Core if there
// persisted, or the time of the first report for OpenTF Core if there
// hasn't yet been a persisted snapshot.
LastPersist time.Time
// ForcePersist is true when Terraform CLI has receieved an interrupt
// ForcePersist is true when OpenTF CLI has received an interrupt
// signal and is therefore trying to create snapshots more aggressively
// in anticipation of possibly being terminated ungracefully.
// [IntermediateStateConditionalPersister] implementations should ideally
@ -97,17 +97,17 @@ func (h *StateHook) Stopping() {
h.Lock()
defer h.Unlock()
// If Terraform has been asked to stop then that might mean that a hard
// kill signal will follow shortly in case Terraform doesn't stop
// If OpenTF has been asked to stop then that might mean that a hard
// kill signal will follow shortly in case OpenTF doesn't stop
// quickly enough, and so we'll try to persist the latest state
// snapshot in the hope that it'll give the user less recovery work to
// do if they _do_ subsequently hard-kill Terraform during an apply.
// do if they _do_ subsequently hard-kill OpenTF during an apply.
if mgrPersist, ok := h.StateMgr.(statemgr.Persister); ok && h.Schemas != nil {
// While we're in the stopping phase we'll try to persist every
// new state update to maximize every opportunity we get to avoid
// losing track of objects that have been created or updated.
// Terraform Core won't start any new operations after it's been
// OpenTF Core won't start any new operations after it's been
// stopped, so at most we should see one more PostStateUpdate
// call per already-active request.
h.intermediatePersist.ForcePersist = true
@ -115,8 +115,8 @@ func (h *StateHook) Stopping() {
if h.shouldPersist() {
err := mgrPersist.PersistState(h.Schemas)
if err != nil {
// This hook can't affect Terraform Core's ongoing behavior,
// but it's a best effort thing anyway so we'll just emit a
// This hook can't affect OpenTF Core's ongoing behavior,
// but it's a best effort thing anyway, so we'll just emit a
// log to aid with debugging.
log.Printf("[ERROR] Failed to persist state after interruption: %s", err)
}
@ -146,7 +146,7 @@ func DefaultIntermediateStatePersistRule(info *IntermediateStatePersistInfo) boo
// IntermediateStateConditionalPersister is an optional extension of
// [statemgr.Persister] that allows an implementation to tailor the rules for
// whether to create intermediate state snapshots when Terraform Core emits
// whether to create intermediate state snapshots when OpenTF Core emits
// events reporting that the state might have changed.
//
// For state managers that don't implement this interface, [StateHook] uses
@ -156,7 +156,7 @@ func DefaultIntermediateStatePersistRule(info *IntermediateStatePersistInfo) boo
// to change over time, but a state manager can implement this interface to
// exert full control over those rules.
type IntermediateStateConditionalPersister interface {
// ShouldPersistIntermediateState will be called each time Terraform Core
// ShouldPersistIntermediateState will be called each time OpenTF Core
// emits an intermediate state event that is potentially eligible to be
// persisted.
//

View File

@ -6,7 +6,7 @@ package backend
//go:generate go run golang.org/x/tools/cmd/stringer -type=OperationType operation_type.go
// OperationType is an enum used with Operation to specify the operation
// type to perform for Terraform.
// type to perform for OpenTF.
type OperationType uint
const (

View File

@ -174,7 +174,7 @@ func New() backend.Backend {
"use_azuread_auth": {
Type: schema.TypeBool,
Optional: true,
Description: "Should Terraform use AzureAD Authentication to access the Blob?",
Description: "Should OpenTF use AzureAD Authentication to access the Blob?",
DefaultFunc: schema.EnvDefaultFunc("ARM_USE_AZUREAD", false),
},
},

View File

@ -364,7 +364,7 @@ func (c *RemoteClient) Lock(info *statemgr.LockInfo) (string, error) {
c.info = info
// These checks only are to ensure we strictly follow the specification.
// Terraform shouldn't ever re-lock, so provide errors for the 2 possible
// OpenTF shouldn't ever re-lock, so provide errors for the 2 possible
// states if this is called.
select {
case <-c.lockCh:
@ -402,7 +402,7 @@ func (c *RemoteClient) lock() (string, error) {
Key: c.lockPath() + lockSuffix,
Session: lockSession,
// only wait briefly, so terraform has the choice to fail fast or
// only wait briefly, so opentf has the choice to fail fast or
// retry as needed.
LockWaitTime: time.Second,
LockTryOnce: true,
@ -482,7 +482,7 @@ func (c *RemoteClient) lock() (string, error) {
if err != nil {
// We failed to get the lock, keep trying as long as
// terraform is running. There may be changes in progress,
// opentf is running. There may be changes in progress,
// so there's no use in aborting. Either we eventually
// reacquire the lock, or a Put will fail on a CAS.
log.Printf("[ERROR] could not reacquire lock: %s", err)
@ -559,11 +559,11 @@ func (c *RemoteClient) unlock(id string) error {
// This method can be called in two circumstances:
// - when the plan apply or destroy operation finishes and the lock needs to be released,
// the watchdog stopped and the session closed
// - when the user calls `terraform force-unlock <lock_id>` in which case
// - when the user calls `opentf force-unlock <lock_id>` in which case
// we only need to release the lock.
if c.consulLock == nil || c.lockCh == nil {
// The user called `terraform force-unlock <lock_id>`, we just destroy
// The user called `opentf force-unlock <lock_id>`, we just destroy
// the session which will release the lock, clean the KV store and quit.
_, err := c.Client.Session().Destroy(id, nil)

View File

@ -318,7 +318,7 @@ func TestConsul_destroyLock(t *testing.T) {
testLock(clientA, lockPath)
// The release the lock from a second client to test the
// `terraform force-unlock <lock_id>` functionnality
// `opentf force-unlock <lock_id>` functionality
s, err = b.StateMgr(backend.DefaultStateName)
if err != nil {
t.Fatalf("err: %s", err)

View File

@ -142,7 +142,7 @@ func New() backend.Backend {
Type: schema.TypeSet,
Optional: true,
MaxItems: 1,
Description: "The `assume_role` block. If provided, terraform will attempt to assume this role using the supplied credentials.",
Description: "The `assume_role` block. If provided, opentf will attempt to assume this role using the supplied credentials.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"role_arn": {

View File

@ -196,7 +196,7 @@ func (c *RemoteClient) Lock(info *statemgr.LockInfo) (string, error) {
lockErr := &statemgr.LockError{
Info: currentLockInfo,
Err: errors.New("the state is already locked by another terraform client"),
Err: errors.New("the state is already locked by another opentf client"),
}
return "", lockErr
}

View File

@ -51,21 +51,21 @@ func New() backend.Backend {
"skip_schema_creation": {
Type: schema.TypeBool,
Optional: true,
Description: "If set to `true`, Terraform won't try to create the Postgres schema",
Description: "If set to `true`, OpenTF won't try to create the Postgres schema",
DefaultFunc: defaultBoolFunc("PG_SKIP_SCHEMA_CREATION", false),
},
"skip_table_creation": {
Type: schema.TypeBool,
Optional: true,
Description: "If set to `true`, Terraform won't try to create the Postgres table",
Description: "If set to `true`, OpenTF won't try to create the Postgres table",
DefaultFunc: defaultBoolFunc("PG_SKIP_TABLE_CREATION", false),
},
"skip_index_creation": {
Type: schema.TypeBool,
Optional: true,
Description: "If set to `true`, Terraform won't try to create the Postgres index",
Description: "If set to `true`, OpenTF won't try to create the Postgres index",
DefaultFunc: defaultBoolFunc("PG_SKIP_INDEX_CREATION", false),
},
},

View File

@ -51,7 +51,7 @@ type Remote 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 OpenTF context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *terraform.ContextOpts
@ -89,7 +89,7 @@ type Remote struct {
opLock sync.Mutex
// ignoreVersionConflict, if true, will disable the requirement that the
// local Terraform version matches the remote workspace's configured
// local OpenTF version matches the remote workspace's configured
// version. This will also cause VerifyWorkspaceTerraformVersion to return
// a warning diagnostic instead of an error.
ignoreVersionConflict bool
@ -306,7 +306,7 @@ func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
// Return an error if we still don't have a token at this point.
if token == "" {
loginCommand := "terraform login"
loginCommand := "opentf login"
if b.hostname != defaultHostname {
loginCommand = loginCommand + " " + b.hostname
}
@ -485,14 +485,14 @@ func (b *Remote) checkConstraints(c *disco.Constraints) tfdiags.Diagnostics {
excluding = ""
}
summary := fmt.Sprintf("Incompatible Terraform version v%s", v.String())
summary := fmt.Sprintf("Incompatible OpenTF version v%s", v.String())
details := fmt.Sprintf(
"The configured Terraform Enterprise backend is compatible with Terraform "+
"The configured OpenTF Enterprise backend is compatible with OpenTF "+
"versions >= %s, <= %s%s.", c.Minimum, c.Maximum, excluding,
)
if action != "" && toVersion != "" {
summary = fmt.Sprintf("Please %s Terraform to %s", action, toVersion)
summary = fmt.Sprintf("Please %s OpenTF to %s", action, toVersion)
details += fmt.Sprintf(" Please %s to a supported version and try again.", action)
}
@ -662,7 +662,7 @@ func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
Name: tfe.String(name),
}
// We only set the Terraform Version for the new workspace if this is
// We only set the OpenTF Version for the new workspace if this is
// a release candidate or a final release.
if tfversion.Prerelease == "" || strings.HasPrefix(tfversion.Prerelease, "rc") {
options.TerraformVersion = tfe.String(tfversion.String())
@ -684,7 +684,7 @@ func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
// Explicitly ignore the pseudo-version "latest" here, as it will cause
// plan and apply to always fail.
if wsv != tfversion.String() && wsv != "latest" {
return nil, fmt.Errorf("Remote workspace Terraform version %q does not match local Terraform version %q", workspace.TerraformVersion, tfversion.String())
return nil, fmt.Errorf("Remote workspace OpenTF version %q does not match local OpenTF version %q", workspace.TerraformVersion, tfversion.String())
}
}
@ -693,14 +693,14 @@ func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
organization: b.organization,
workspace: workspace,
// This is optionally set during Terraform Enterprise runs.
// This is optionally set during OpenTF Enterprise runs.
runID: os.Getenv("TFE_RUN_ID"),
}
return &remote.State{
Client: client,
// client.runID will be set if we're running a the Terraform Cloud
// client.runID will be set if we're running a Terraform Cloud
// or Terraform Enterprise remote execution environment, in which
// case we'll disable intermediate snapshots to avoid extra storage
// costs for Terraform Enterprise customers.
@ -751,14 +751,14 @@ func (b *Remote) Operation(ctx context.Context, op *backend.Operation) (*backend
return nil, err
}
// Terraform remote version conflicts are not a concern for operations. We
// OpenTF remote version conflicts are not a concern for operations. We
// are in one of three states:
//
// - Running remotely, in which case the local version is irrelevant;
// - Workspace configured for local operations, in which case the remote
// version is meaningless;
// - Forcing local operations with a remote backend, which should only
// happen in the Terraform Cloud worker, in which case the Terraform
// happen in the Terraform Cloud worker, in which case the OpenTF
// versions by definition match.
b.IgnoreVersionConflict()
@ -784,7 +784,7 @@ func (b *Remote) Operation(ctx context.Context, op *backend.Operation) (*backend
case backend.OperationTypeRefresh:
return nil, fmt.Errorf(
"\n\nThe \"refresh\" operation is not supported when using the \"remote\" backend. " +
"Use \"terraform apply -refresh-only\" instead.")
"Use \"opentf apply -refresh-only\" instead.")
default:
return nil, fmt.Errorf(
"\n\nThe \"remote\" backend does not support the %q operation.", op.Type)
@ -904,8 +904,8 @@ func (b *Remote) 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 OpenTF version matches the remote workspace's configured
// OpenTF 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.
@ -913,8 +913,8 @@ func (b *Remote) IgnoreVersionConflict() {
b.ignoreVersionConflict = true
}
// VerifyWorkspaceTerraformVersion compares the local Terraform version against
// the workspace's configured Terraform version. If they are equal, this means
// VerifyWorkspaceTerraformVersion compares the local OpenTF version against
// the workspace's configured OpenTF version. If they are equal, this means
// that there are no compatibility concerns, so it returns no diagnostics.
//
// If the versions differ,
@ -939,13 +939,13 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
}
// 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 OpenTF version is, so
// we'll skip version verification.
if workspace.TerraformVersion == "latest" {
return nil
}
// If the workspace has remote operations disabled, the remote Terraform
// If the workspace has remote operations disabled, the remote OpenTF
// version is effectively meaningless, so we'll skip version verification.
if isLocalExecutionMode(workspace.ExecutionMode) {
return nil
@ -956,22 +956,22 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Error looking up workspace",
fmt.Sprintf("Invalid Terraform version: %s", err),
fmt.Sprintf("Invalid OpenTF version: %s", err),
))
return diags
}
v014 := version.Must(version.NewSemver("0.14.0"))
if tfversion.SemVer.LessThan(v014) || remoteVersion.LessThan(v014) {
// Versions of Terraform prior to 0.14.0 will refuse to load state files
// written by a newer version of Terraform, even if it is only a patch
// Versions of OpenTF prior to 0.14.0 will refuse to load state files
// written by a newer version of OpenTF, even if it is only a patch
// level difference. As a result we require an exact match.
if tfversion.SemVer.Equal(remoteVersion) {
return diags
}
}
if tfversion.SemVer.GreaterThanOrEqual(v014) && remoteVersion.GreaterThanOrEqual(v014) {
// Versions of Terraform after 0.14.0 should be compatible with each
// Versions of OpenTF after 0.14.0 should be compatible with each
// other. At the time this code was written, the only constraints we
// are aware of are:
//
@ -981,7 +981,7 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
if tfversion.SemVer.LessThan(v130) && remoteVersion.LessThan(v130) {
return diags
}
// - Any new Terraform state version will require at least minor patch
// - Any new OpenTF state version will require at least minor patch
// increment, so x.y.* will always be compatible with each other
tfvs := tfversion.SemVer.Segments64()
rwvs := remoteVersion.Segments64()
@ -992,21 +992,21 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
// Even if ignoring version conflicts, it may still be useful to call this
// method and warn the user about a mismatch between the local and remote
// Terraform versions.
// OpenTF versions.
severity := tfdiags.Error
if b.ignoreVersionConflict {
severity = tfdiags.Warning
}
suggestion := " If you're sure you want to upgrade the state, you can force Terraform to continue using the -ignore-remote-version flag. This may result in an unusable workspace."
suggestion := " If you're sure you want to upgrade the state, you can force OpenTF to continue using the -ignore-remote-version flag. This may result in an unusable workspace."
if b.ignoreVersionConflict {
suggestion = ""
}
diags = diags.Append(tfdiags.Sourceless(
severity,
"Terraform version mismatch",
"OpenTF version mismatch",
fmt.Sprintf(
"The local Terraform version (%s) does not match the configured version for remote workspace %s/%s (%s).%s",
"The local OpenTF version (%s) does not match the configured version for remote workspace %s/%s (%s).%s",
tfversion.String(),
b.organization,
workspace.Name,
@ -1066,7 +1066,7 @@ func checkConstraintsWarning(err error) tfdiags.Diagnostic {
// The newline in this error is to make it look good in the CLI!
const initialRetryError = `
[reset][yellow]There was an error connecting to the remote backend. Please do not exit
Terraform to prevent data loss! Trying to restore the connection...
OpenTF to prevent data loss! Trying to restore the connection...
[reset]
`

View File

@ -72,7 +72,7 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
"Currently the only to way to pass variables to the remote backend is by "+
"creating a '*.auto.tfvars' variables file. This file will automatically "+
"be loaded by the \"remote\" backend when the workspace is configured to use "+
"Terraform v0.10.0 or later.\n\nAdditionally you can also set variables on "+
"OpenTF v0.10.0 or later.\n\nAdditionally you can also set variables on "+
"the workspace in the web UI:\nhttps://%s/app/%s/%s/variables",
b.hostname, b.organization, op.Workspace,
),
@ -85,7 +85,7 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
"No configuration files found",
`Apply requires configuration to be present. Applying without a configuration `+
`would mark everything for destruction, which is normally not what is desired. `+
`If you would like to destroy everything, please run 'terraform destroy' which `+
`If you would like to destroy everything, please run 'opentf destroy' which `+
`does not require any configuration files.`,
))
}
@ -224,11 +224,11 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
if op.PlanMode == plans.DestroyMode {
opts.Query = "\nDo you really want to destroy all resources in workspace \"" + op.Workspace + "\"?"
opts.Description = "Terraform will destroy all your managed infrastructure, as shown above.\n" +
opts.Description = "OpenTF will destroy all your managed infrastructure, as shown above.\n" +
"There is no undo. Only 'yes' will be accepted to confirm."
} else {
opts.Query = "\nDo you want to perform these actions in workspace \"" + op.Workspace + "\"?"
opts.Description = "Terraform will perform the actions described above.\n" +
opts.Description = "OpenTF will perform the actions described above.\n" +
"Only 'yes' will be accepted to approve."
}

View File

@ -215,7 +215,7 @@ func stubAllVariables(vv map[string]backend.UnparsedVariableValue, decls map[str
// remoteStoredVariableValue is a backend.UnparsedVariableValue implementation
// that translates from the go-tfe representation of stored variables into
// the Terraform Core backend representation of variables.
// the OpenTF Core backend representation of variables.
type remoteStoredVariableValue struct {
definition *tfe.Variable
}
@ -250,7 +250,7 @@ func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariablePars
case v.definition.HCL:
// If the variable value is marked as being in HCL syntax, we need to
// parse it the same way as it would be interpreted in a .tfvars
// file because that is how it would get passed to Terraform CLI for
// file because that is how it would get passed to OpenTF CLI for
// a remote operation and we want to mimic that result as closely as
// possible.
var exprDiags hcl.Diagnostics

View File

@ -91,7 +91,7 @@ func TestRemoteStoredVariableValue(t *testing.T) {
"HCL computation": {
// This (stored expressions containing computation) is not a case
// we intentionally supported, but it became possible for remote
// operations in Terraform 0.12 (due to Terraform Cloud/Enterprise
// operations in OpenTF 0.12 (due to Terraform Cloud/Enterprise
// just writing the HCL verbatim into generated `.tfvars` files).
// We support it here for consistency, and we continue to support
// it in both places for backward-compatibility. In practice,

View File

@ -87,7 +87,7 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio
"Currently the only to way to pass variables to the remote backend is by "+
"creating a '*.auto.tfvars' variables file. This file will automatically "+
"be loaded by the \"remote\" backend when the workspace is configured to use "+
"Terraform v0.10.0 or later.\n\nAdditionally you can also set variables on "+
"OpenTF v0.10.0 or later.\n\nAdditionally you can also set variables on "+
"the workspace in the web UI:\nhttps://%s/app/%s/%s/variables",
b.hostname, b.organization, op.Workspace,
),
@ -102,7 +102,7 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio
`would mark everything for destruction, which is normally not what is desired. `+
`If you would like to destroy everything, please run plan with the "-destroy" `+
`flag or create a single empty configuration file. Otherwise, please create `+
`a Terraform configuration file in the path being executed and try again.`,
`a OpenTF configuration file in the path being executed and try again.`,
))
}
@ -230,7 +230,7 @@ func (b *Remote) plan(stopCtx, cancelCtx context.Context, op *backend.Operation,
The remote workspace is configured to work with configuration at
%s relative to the target repository.
Terraform will upload the contents of the following directory,
OpenTF will upload the contents of the following directory,
excluding files or directories as defined by a .terraformignore file
at %s/.terraformignore (if it is present),
in order to capture the filesystem context the remote workspace expects:

View File

@ -92,7 +92,7 @@ func (r *remoteClient) uploadStateFallback(ctx context.Context, stateFile *state
func (r *remoteClient) Put(state []byte) error {
ctx := context.Background()
// Read the raw state into a Terraform state.
// Read the raw state into a OpenTF state.
stateFile, err := statefile.Read(bytes.NewReader(state))
if err != nil {
return fmt.Errorf("error reading state: %s", err)
@ -164,7 +164,7 @@ func (r *remoteClient) Lock(info *statemgr.LockInfo) (string, error) {
// Lock the workspace.
_, err := r.client.Workspaces.Lock(ctx, r.workspace.ID, tfe.WorkspaceLockOptions{
Reason: tfe.String("Locked by Terraform"),
Reason: tfe.String("Locked by OpenTF"),
})
if err != nil {
if err == tfe.ErrWorkspaceLocked {

View File

@ -83,7 +83,7 @@ func TestRemote_config(t *testing.T) {
"prefix": cty.NullVal(cty.String),
}),
}),
confErr: "terraform login localhost",
confErr: "opentf login localhost",
},
"with_a_name": {
config: cty.ObjectVal(map[string]cty.Value{
@ -186,7 +186,7 @@ func TestRemote_versionConstraints(t *testing.T) {
}),
}),
version: "0.0.1",
result: "upgrade Terraform to >= 0.1.0",
result: "upgrade OpenTF to >= 0.1.0",
},
"version too new": {
config: cty.ObjectVal(map[string]cty.Value{
@ -199,7 +199,7 @@ func TestRemote_versionConstraints(t *testing.T) {
}),
}),
version: "10.0.1",
result: "downgrade Terraform to <= 10.0.0",
result: "downgrade OpenTF to <= 10.0.0",
},
}
@ -379,7 +379,7 @@ func TestRemote_checkConstraints(t *testing.T) {
Maximum: "0.11.11",
},
version: "0.10.1",
result: "upgrade Terraform to >= 0.11.0",
result: "upgrade OpenTF to >= 0.11.0",
},
"version too new": {
constraints: &disco.Constraints{
@ -387,7 +387,7 @@ func TestRemote_checkConstraints(t *testing.T) {
Maximum: "0.11.11",
},
version: "0.12.0",
result: "downgrade Terraform to <= 0.11.11",
result: "downgrade OpenTF to <= 0.11.11",
},
"version excluded - ordered": {
constraints: &disco.Constraints{
@ -396,7 +396,7 @@ func TestRemote_checkConstraints(t *testing.T) {
Maximum: "0.11.11",
},
version: "0.11.7",
result: "upgrade Terraform to > 0.11.8",
result: "upgrade OpenTF to > 0.11.8",
},
"version excluded - unordered": {
constraints: &disco.Constraints{
@ -405,7 +405,7 @@ func TestRemote_checkConstraints(t *testing.T) {
Maximum: "0.11.11",
},
version: "0.11.6",
result: "upgrade Terraform to > 0.11.8",
result: "upgrade OpenTF to > 0.11.8",
},
"list versions": {
constraints: &disco.Constraints{
@ -481,7 +481,7 @@ func TestRemote_StateMgr_versionCheck(t *testing.T) {
tfversion.Version = v0140.String()
tfversion.SemVer = v0140
// Update the mock remote workspace Terraform version to match the local
// Update the mock remote workspace OpenTF version to match the local
// Terraform version
if _, err := b.client.Workspaces.Update(
context.Background(),
@ -512,7 +512,7 @@ func TestRemote_StateMgr_versionCheck(t *testing.T) {
}
// This should fail
want := `Remote workspace Terraform version "0.13.5" does not match local Terraform version "0.14.0"`
want := `Remote workspace OpenTF version "0.13.5" does not match local OpenTF version "0.14.0"`
if _, err := b.StateMgr(backend.DefaultStateName); err.Error() != want {
t.Fatalf("wrong error\n got: %v\nwant: %v", err.Error(), want)
}
@ -597,7 +597,7 @@ func TestRemote_VerifyWorkspaceTerraformVersion(t *testing.T) {
tfversion.Version = local.String()
tfversion.SemVer = local
// Update the mock remote workspace Terraform version to the
// Update the mock remote workspace OpenTF version to the
// specified remote version
if _, err := b.client.Workspaces.Update(
context.Background(),
@ -616,7 +616,7 @@ func TestRemote_VerifyWorkspaceTerraformVersion(t *testing.T) {
if len(diags) != 1 {
t.Fatal("expected diag, but none returned")
}
if got := diags.Err().Error(); !strings.Contains(got, "Terraform version mismatch") {
if got := diags.Err().Error(); !strings.Contains(got, "OpenTF version mismatch") {
t.Fatalf("unexpected error: %s", got)
}
} else {
@ -649,7 +649,7 @@ func TestRemote_VerifyWorkspaceTerraformVersion_workspaceErrors(t *testing.T) {
t.Fatalf("unexpected error: %s", got)
}
// Update the mock remote workspace Terraform version to an invalid version
// Update the mock remote workspace OpenTF version to an invalid version
if _, err := b.client.Workspaces.Update(
context.Background(),
b.organization,
@ -665,7 +665,7 @@ func TestRemote_VerifyWorkspaceTerraformVersion_workspaceErrors(t *testing.T) {
if len(diags) != 1 {
t.Fatal("expected diag, but none returned")
}
if got := diags.Err().Error(); !strings.Contains(got, "Error looking up workspace: Invalid Terraform version") {
if got := diags.Err().Error(); !strings.Contains(got, "Error looking up workspace: Invalid OpenTF version") {
t.Fatalf("unexpected error: %s", got)
}
}
@ -696,7 +696,7 @@ func TestRemote_VerifyWorkspaceTerraformVersion_ignoreFlagSet(t *testing.T) {
tfversion.Version = local.String()
tfversion.SemVer = local
// Update the mock remote workspace Terraform version to the
// Update the mock remote workspace OpenTF version to the
// specified remote version
if _, err := b.client.Workspaces.Update(
context.Background(),
@ -717,10 +717,10 @@ func TestRemote_VerifyWorkspaceTerraformVersion_ignoreFlagSet(t *testing.T) {
if got, want := diags[0].Severity(), tfdiags.Warning; got != want {
t.Errorf("wrong severity: got %#v, want %#v", got, want)
}
if got, want := diags[0].Description().Summary, "Terraform version mismatch"; got != want {
if got, want := diags[0].Description().Summary, "OpenTF version mismatch"; got != want {
t.Errorf("wrong summary: got %s, want %s", got, want)
}
wantDetail := "The local Terraform version (0.14.0) does not match the configured version for remote workspace hashicorp/prod (0.13.5)."
wantDetail := "The local OpenTF version (0.14.0) does not match the configured version for remote workspace hashicorp/prod (0.13.5)."
if got := diags[0].Description().Detail; got != wantDetail {
t.Errorf("wrong summary: got %s, want %s", got, wantDetail)
}

View File

@ -165,19 +165,19 @@ func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*
diags = diags.Append(diagsUndeclared)
// By this point we should've gathered all of the required root module
// By this point we should've gathered all the required root module
// variables from one of the many possible sources. We'll now populate
// any we haven't gathered as unset placeholders which Terraform Core
// any we haven't gathered as unset placeholders which OpenTF Core
// can then react to.
for name, vc := range decls {
if isDefinedAny(name, ret, undeclared) {
continue
}
// This check is redundant with a check made in Terraform Core when
// This check is redundant with a check made in OpenTF Core when
// processing undeclared variables, but allows us to generate a more
// specific error message which mentions -var and -var-file command
// line options, whereas the one in Terraform Core is more general
// line options, whereas the one in OpenTF Core is more general
// due to supporting both root and child module variables.
if vc.Required() {
diags = diags.Append(&hcl.Diagnostic{
@ -198,9 +198,9 @@ func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*
}
} else {
// We're still required to put an entry for this variable
// in the mapping to be explicit to Terraform Core that we
// in the mapping to be explicit to OpenTF Core that we
// visited it, but its value will be cty.NilVal to represent
// that it wasn't set at all at this layer, and so Terraform Core
// that it wasn't set at all at this layer, and so OpenTF Core
// should substitute a default if available, or generate an error
// if not.
ret[name] = &terraform.InputValue{

View File

@ -207,7 +207,7 @@ func TestUnparsedValue(t *testing.T) {
},
},
"missing2": {
Value: cty.NilVal, // Terraform Core handles substituting the default
Value: cty.NilVal, // OpenTF Core handles substituting the default
SourceType: terraform.ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tf",

View File

@ -163,7 +163,7 @@ func TestProviderTampering(t *testing.T) {
if want := `provider registry.terraform.io/hashicorp/null: locked version selection 3.1.0 doesn't match the updated version constraints "1.0.0"`; !strings.Contains(stderr, want) {
t.Errorf("missing expected error message\nwant substring: %s\ngot:\n%s", want, stderr)
}
if want := `terraform init -upgrade`; !strings.Contains(stderr, want) {
if want := `opentf init -upgrade`; !strings.Contains(stderr, want) {
t.Errorf("missing expected error message\nwant substring: %s\ngot:\n%s", want, stderr)
}
})
@ -189,7 +189,7 @@ func TestProviderTampering(t *testing.T) {
if want := `provider registry.terraform.io/hashicorp/null: required by this configuration but no version is selected`; !strings.Contains(stderr, want) {
t.Errorf("missing expected error message\nwant substring: %s\ngot:\n%s", want, stderr)
}
if want := `terraform init`; !strings.Contains(stderr, want) {
if want := `opentf init`; !strings.Contains(stderr, want) {
t.Errorf("missing expected error message\nwant substring: %s\ngot:\n%s", want, stderr)
}
})

View File

@ -103,7 +103,7 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
renderer.Streams.Println()
}
renderer.Streams.Print(
renderer.Colorize.Color("\n[reset][bold][red]Planning failed.[reset][bold] Terraform encountered an error while generating this plan.[reset]\n\n"),
renderer.Colorize.Color("\n[reset][bold][red]Planning failed.[reset][bold] OpenTF encountered an error while generating this plan.[reset]\n\n"),
)
} else {
switch mode {
@ -117,7 +117,7 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
renderer.Streams.Print(renderer.Colorize.Color("\n[reset][bold][green]No changes.[reset][bold] Your infrastructure still matches the configuration.[reset]\n\n"))
renderer.Streams.Println(format.WordWrap(
"Terraform has checked that the real remote objects still match the result of your most recent changes, and found no differences.",
"OpenTF has checked that the real remote objects still match the result of your most recent changes, and found no differences.",
renderer.Streams.Stdout.Columns()))
case plans.DestroyMode:
if haveRefreshChanges {
@ -126,7 +126,7 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
}
renderer.Streams.Print(renderer.Colorize.Color("\n[reset][bold][green]No changes.[reset][bold] No objects need to be destroyed.[reset]\n\n"))
renderer.Streams.Println(format.WordWrap(
"Either you have not created any objects yet or the existing objects were already deleted outside of Terraform.",
"Either you have not created any objects yet or the existing objects were already deleted outside of OpenTF.",
renderer.Streams.Stdout.Columns()))
default:
if haveRefreshChanges {
@ -155,10 +155,10 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
suggestion := "."
if !renderer.RunningInAutomation {
// The normal message includes a specific command line to run.
suggestion = ":\n terraform apply -refresh-only"
suggestion = ":\n opentf apply -refresh-only"
}
renderer.Streams.Println(format.WordWrap(
"Your configuration already matches the changes detected above. If you'd like to update the Terraform state to match, create and apply a refresh-only plan"+suggestion,
"Your configuration already matches the changes detected above. If you'd like to update the OpenTF state to match, create and apply a refresh-only plan"+suggestion,
renderer.Streams.Stdout.Columns(),
))
}
@ -168,7 +168,7 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
// If we get down here then we're just in the simple situation where
// the plan isn't applyable at all.
renderer.Streams.Println(format.WordWrap(
"Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.",
"OpenTF has compared your real infrastructure against your configuration and found no differences, so no changes are needed.",
renderer.Streams.Stdout.Columns(),
))
}
@ -182,7 +182,7 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
if willPrintResourceChanges {
renderer.Streams.Println(format.WordWrap(
"\nTerraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:",
"\nOpenTF used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:",
renderer.Streams.Stdout.Columns()))
if counts[plans.Create] > 0 {
renderer.Streams.Println(renderer.Colorize.Color(actionDescription(plans.Create)))
@ -206,9 +206,9 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
if len(changes) > 0 {
if checkOpts(plans.Errored) {
renderer.Streams.Printf("\nTerraform planned the following actions, but then encountered a problem:\n")
renderer.Streams.Printf("\nOpenTF planned the following actions, but then encountered a problem:\n")
} else {
renderer.Streams.Printf("\nTerraform will perform the following actions:\n")
renderer.Streams.Printf("\nOpenTF will perform the following actions:\n")
}
for _, change := range changes {
@ -245,7 +245,7 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
// so we need some extra context about what it would mean to
// apply a change that _only_ includes output changes.
renderer.Streams.Println(format.WordWrap(
"\nYou can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.",
"\nYou can apply this plan to save these new output values to the OpenTF state, without changing any real infrastructure.",
renderer.Streams.Stdout.Columns()))
}
}
@ -304,10 +304,10 @@ func renderHumanDiffDrift(renderer Renderer, diffs diffs, mode plans.Mode) bool
return false
}
renderer.Streams.Print(renderer.Colorize.Color("\n[bold][cyan]Note:[reset][bold] Objects have changed outside of Terraform\n"))
renderer.Streams.Print(renderer.Colorize.Color("\n[bold][cyan]Note:[reset][bold] Objects have changed outside of OpenTF\n"))
renderer.Streams.Println()
renderer.Streams.Print(format.WordWrap(
"Terraform detected the following changes made outside of Terraform since the last \"terraform apply\" which may have affected this plan:\n",
"OpenTF detected the following changes made outside of OpenTF since the last \"opentf apply\" which may have affected this plan:\n",
renderer.Streams.Stdout.Columns()))
for _, drift := range drs {
@ -321,7 +321,7 @@ func renderHumanDiffDrift(renderer Renderer, diffs diffs, mode plans.Mode) bool
switch mode {
case plans.RefreshOnlyMode:
renderer.Streams.Println(format.WordWrap(
"\n\nThis is a refresh-only plan, so Terraform will not take any actions to undo these. If you were expecting these changes then you can apply this plan to record the updated values in the Terraform state without changing any remote objects.",
"\n\nThis is a refresh-only plan, so OpenTF will not take any actions to undo these. If you were expecting these changes then you can apply this plan to record the updated values in the OpenTF state without changing any remote objects.",
renderer.Streams.Stdout.Columns(),
))
default:
@ -395,7 +395,7 @@ func resourceChangeComment(resource jsonplan.ResourceChange, action plans.Action
case plans.CreateThenDelete, plans.DeleteThenCreate:
switch resource.ActionReason {
case jsonplan.ResourceInstanceReplaceBecauseTainted:
buf.WriteString(fmt.Sprintf("[bold] # %s[reset] is tainted, so must be [bold][red]replaced[reset]", dispAddr))
buf.WriteString(fmt.Sprintf("[bold] # %s[reset] is tainted, so it must be [bold][red]replaced[reset]", dispAddr))
case jsonplan.ResourceInstanceReplaceByRequest:
buf.WriteString(fmt.Sprintf("[bold] # %s[reset] will be [bold][red]replaced[reset], as requested", dispAddr))
case jsonplan.ResourceInstanceReplaceByTriggers:
@ -426,7 +426,7 @@ func resourceChangeComment(resource jsonplan.ResourceChange, action plans.Action
// FIXME: Ideally we'd truncate addr.Module to reflect the earliest
// step that doesn't exist, so it's clearer which call this refers
// to, but we don't have enough information out here in the UI layer
// to decide that; only the "expander" in Terraform Core knows
// to decide that; only the "expander" in OpenTF Core knows
// which module instance keys are actually declared.
buf.WriteString(fmt.Sprintf("\n # (because %s is not in configuration)", resource.ModuleAddress))
case jsonplan.ResourceInstanceDeleteBecauseWrongRepetition:

View File

@ -39,8 +39,8 @@ func TestRenderHuman_EmptyPlan(t *testing.T) {
want := `
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
OpenTF has compared your real infrastructure against your configuration and
found no differences, so no changes are needed.
`
got := done(t).Stdout()
@ -70,8 +70,8 @@ func TestRenderHuman_EmptyOutputs(t *testing.T) {
want := `
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
OpenTF has compared your real infrastructure against your configuration and
found no differences, so no changes are needed.
`
got := done(t).Stdout()
@ -133,7 +133,7 @@ func TestRenderHuman_Imports(t *testing.T) {
},
},
output: `
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.resource will be imported
resource "test_resource" "resource" {
@ -175,7 +175,7 @@ Plan: 1 to import, 0 to add, 0 to change, 0 to destroy.
},
},
output: `
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.resource will be imported
# (config will be generated)
@ -215,7 +215,7 @@ Plan: 1 to import, 0 to add, 0 to change, 0 to destroy.
},
},
output: `
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.before has moved to test_resource.after
# (imported from "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E")
@ -255,11 +255,11 @@ Plan: 1 to import, 0 to add, 0 to change, 0 to destroy.
},
},
output: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.after will be updated in-place
# (moved from test_resource.before)
@ -299,11 +299,11 @@ Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.
},
},
output: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.resource will be updated in-place
# (imported from "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E")
@ -340,11 +340,11 @@ Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.
},
},
output: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.resource will be updated in-place
# (will be imported first)
@ -385,11 +385,11 @@ Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.
},
},
output: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+/- create replacement and then destroy
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.resource must be replaced
# (imported from "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E")
@ -863,7 +863,7 @@ new line`),
RequiredReplace: cty.NewPathSet(cty.Path{
cty.GetAttrStep{Name: "ami"},
}),
ExpectedOutput: ` # test_instance.example is tainted, so must be replaced
ExpectedOutput: ` # test_instance.example is tainted, so it must be replaced
-/+ resource "test_instance" "example" {
~ ami = "ami-BEFORE" -> "ami-AFTER" # forces replacement
~ id = "i-02ae66f368e8518a9" -> (known after apply)
@ -5844,7 +5844,7 @@ func TestResourceChange_actionReason(t *testing.T) {
After: nullVal,
Schema: emptySchema,
RequiredReplace: cty.NewPathSet(),
ExpectedOutput: ` # test_instance.example is tainted, so must be replaced
ExpectedOutput: ` # test_instance.example is tainted, so it must be replaced
-/+ resource "test_instance" "example" {}`,
},
"replace because tainted (create first)": {
@ -5855,7 +5855,7 @@ func TestResourceChange_actionReason(t *testing.T) {
After: nullVal,
Schema: emptySchema,
RequiredReplace: cty.NewPathSet(),
ExpectedOutput: ` # test_instance.example is tainted, so must be replaced
ExpectedOutput: ` # test_instance.example is tainted, so it must be replaced
+/- resource "test_instance" "example" {}`,
},
"replace because cannot update (delete first)": {

View File

@ -1247,7 +1247,7 @@ func TestPlan_init_required(t *testing.T) {
t.Fatalf("expected error, got success")
}
got := output.Stderr()
if !(strings.Contains(got, "terraform init") && strings.Contains(got, "provider registry.terraform.io/hashicorp/test: required by this configuration but no version is selected")) {
if !(strings.Contains(got, "opentf init") && strings.Contains(got, "provider registry.terraform.io/hashicorp/test: required by this configuration but no version is selected")) {
t.Fatal("wrong error message in output:", got)
}
}

View File

@ -462,7 +462,7 @@ func TestShow_planErrored(t *testing.T) {
}
got := output.Stdout()
want := `Planning failed. Terraform encountered an error while generating this plan.`
want := `Planning failed. OpenTF encountered an error while generating this plan.`
if !strings.Contains(got, want) {
t.Fatalf("unexpected output\ngot: %s\nwant: %s", got, want)
}

View File

@ -477,11 +477,11 @@ func TestTest_Verbose(t *testing.T) {
expected := `main.tftest.hcl... pass
run "validate_test_resource"... pass
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.foo will be created
+ resource "test_resource" "foo" {
@ -780,11 +780,11 @@ resource "test_resource" "resource" {
}
run "plan_second_example"... pass
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.second_module_resource will be created
+ resource "test_resource" "second_module_resource" {
@ -795,11 +795,11 @@ Terraform will perform the following actions:
Plan: 1 to add, 0 to change, 0 to destroy.
run "plan_update"... pass
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.resource will be updated in-place
~ resource "test_resource" "resource" {
@ -810,11 +810,11 @@ Terraform will perform the following actions:
Plan: 0 to add, 1 to change, 0 to destroy.
run "plan_update_example"... pass
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.module_resource will be updated in-place
~ resource "test_resource" "module_resource" {

View File

@ -100,7 +100,7 @@ func TestOperation_planNoChanges(t *testing.T) {
Changes: plans.NewChanges(),
}
},
"Terraform has checked that the real remote objects still match",
"OpenTF has checked that the real remote objects still match",
},
"nothing at all in destroy mode": {
func(schemas *terraform.Schemas) *plans.Plan {
@ -197,7 +197,7 @@ func TestOperation_planNoChanges(t *testing.T) {
}},
}
},
"Objects have changed outside of Terraform",
"Objects have changed outside of OpenTF",
},
"drift detected in refresh-only mode": {
func(schemas *terraform.Schemas) *plans.Plan {
@ -339,11 +339,11 @@ func TestOperation_plan(t *testing.T) {
v.Plan(plan, schemas)
want := `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.foo will be created
+ resource "test_resource" "foo" {
@ -368,12 +368,12 @@ func TestOperation_planWithDatasource(t *testing.T) {
v.Plan(plan, schemas)
want := `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
<= read (data resources)
Terraform will perform the following actions:
OpenTF will perform the following actions:
# data.test_data_source.bar will be read during apply
<= data "test_data_source" "bar" {
@ -404,12 +404,12 @@ func TestOperation_planWithDatasourceAndDrift(t *testing.T) {
v.Plan(plan, schemas)
want := `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
<= read (data resources)
Terraform will perform the following actions:
OpenTF will perform the following actions:
# data.test_data_source.bar will be read during apply
<= data "test_data_source" "bar" {

View File

@ -612,11 +612,11 @@ something bad happened during this test
},
StdOut: ` run "run_block"... pass
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
OpenTF used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
OpenTF will perform the following actions:
# test_resource.creating will be created
+ resource "test_resource" "creating" {

View File

@ -45,7 +45,7 @@ replacing that object in a similar way to if you had specified that object's
address using `-replace=...` as described above.
```
# aws_instance.example is tainted, so must be replaced
# aws_instance.example is tainted, so it must be replaced
-/+ resource "aws_instance" "example" {
# ...
}

View File

@ -142,7 +142,7 @@ For ease of consumption by callers, the plan representation includes a partial r
// "action_reason" is some optional extra context about why the
// actions given inside "change" were selected. This is the JSON
// equivalent of annotations shown in the normal plan output like
// "is tainted, so must be replaced" as opposed to just "must be
// "is tainted, so it must be replaced" as opposed to just "must be
// replaced".
//
// These reason codes are display hints only and the set of possible