From 3b5b8ba7194b99459167d9a0bf4766b6a74b3e85 Mon Sep 17 00:00:00 2001 From: Kuba Martin Date: Thu, 24 Aug 2023 10:56:05 +0200 Subject: [PATCH] Update `internal/command` to use OpenTF in user-provided strings. (#87) * Update `internal/command` to use OpenTF Signed-off-by: Jakub Martin * Fix e2e tests. Signed-off-by: Jakub Martin * Fix e2e tests. Signed-off-by: Jakub Martin * Fix Signed-off-by: Jakub Martin * Rewrite message. Signed-off-by: Jakub Martin --------- Signed-off-by: Jakub Martin --- internal/command/apply.go | 34 +++---- internal/command/cloud.go | 3 +- internal/command/command.go | 2 +- internal/command/console.go | 10 +-- .../command/console_interactive_solaris.go | 3 +- internal/command/e2etest/init_test.go | 14 +-- .../command/e2etest/module_archive_test.go | 2 +- .../command/e2etest/providers_tamper_test.go | 6 +- internal/command/e2etest/version_test.go | 4 +- internal/command/fmt.go | 12 +-- internal/command/get.go | 8 +- internal/command/graph.go | 6 +- internal/command/helper.go | 6 +- internal/command/import.go | 26 +++--- internal/command/import_test.go | 10 +-- internal/command/init.go | 90 +++++++++---------- internal/command/init_test.go | 14 +-- internal/command/login.go | 63 ++++++------- internal/command/login_test.go | 7 +- internal/command/logout.go | 7 +- internal/command/meta.go | 4 +- internal/command/meta_backend.go | 88 +++++++++--------- internal/command/meta_backend_migrate.go | 32 +++---- internal/command/meta_providers.go | 2 +- internal/command/meta_vars.go | 3 +- internal/command/metadata_command.go | 2 +- internal/command/metadata_functions.go | 7 +- internal/command/output.go | 4 +- internal/command/plan.go | 22 ++--- internal/command/providers.go | 8 +- internal/command/providers_lock.go | 18 ++-- internal/command/providers_lock_test.go | 1 + internal/command/providers_mirror.go | 11 +-- internal/command/providers_schema.go | 4 +- internal/command/push.go | 4 +- internal/command/refresh.go | 8 +- internal/command/show.go | 6 +- internal/command/show_test.go | 21 ++--- internal/command/state_command.go | 4 +- internal/command/state_list.go | 17 ++-- internal/command/state_meta.go | 8 +- internal/command/state_mv.go | 7 +- internal/command/state_pull.go | 4 +- internal/command/state_push.go | 3 +- internal/command/state_replace_provider.go | 7 +- .../command/state_replace_provider_test.go | 2 +- internal/command/state_rm.go | 15 ++-- internal/command/state_show.go | 17 ++-- internal/command/taint.go | 14 +-- internal/command/test.go | 24 ++--- internal/command/unlock.go | 11 +-- internal/command/untaint.go | 14 +-- internal/command/validate.go | 10 +-- internal/command/version.go | 10 +-- internal/command/version_test.go | 5 +- internal/command/workspace_command.go | 16 ++-- internal/command/workspace_delete.go | 11 +-- internal/command/workspace_list.go | 7 +- internal/command/workspace_new.go | 9 +- internal/command/workspace_select.go | 9 +- internal/command/workspace_show.go | 2 +- 61 files changed, 410 insertions(+), 388 deletions(-) diff --git a/internal/command/apply.go b/internal/command/apply.go index 3cdc15aed9..fa536267d9 100644 --- a/internal/command/apply.go +++ b/internal/command/apply.go @@ -185,7 +185,7 @@ func (c *ApplyCommand) LoadPlanFile(path string) (*planfile.WrappedPlanFile, tfd diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Destroy can't be called with a plan file", - fmt.Sprintf("If this plan was created using plan -destroy, apply it using:\n terraform apply %q", path), + fmt.Sprintf("If this plan was created using plan -destroy, apply it using:\n opentf apply %q", path), )) return nil, diags } @@ -221,7 +221,7 @@ func (c *ApplyCommand) PrepareBackend(planFile *planfile.WrappedPlanFile, args * diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to read plan from plan file", - "The given plan file does not have a valid backend configuration. This is a bug in the Terraform command that generated this plan file.", + "The given plan file does not have a valid backend configuration. This is a bug in the OpenTF command that generated this plan file.", )) return nil, diags } @@ -325,15 +325,15 @@ func (c *ApplyCommand) Synopsis() string { func (c *ApplyCommand) helpApply() string { helpText := ` -Usage: terraform [global options] apply [options] [PLAN] +Usage: opentf [global options] apply [options] [PLAN] - Creates or updates infrastructure according to Terraform configuration + Creates or updates infrastructure according to OpenTF configuration files in the current directory. - By default, Terraform will generate a new plan and present it for your + By default, OpenTF will generate a new plan and present it for your approval before taking any action. You can optionally provide a plan - file created by a previous call to "terraform plan", in which case - Terraform will take the actions described in that plan without any + file created by a previous call to "opentf plan", in which case + OpenTF will take the actions described in that plan without any confirmation prompt. Options: @@ -344,12 +344,12 @@ Options: modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup. - -compact-warnings If Terraform produces any warnings that are not + -compact-warnings If OpenTF produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages. - -destroy Destroy Terraform-managed infrastructure. - The command "terraform destroy" is a convenience alias + -destroy Destroy OpenTF-managed infrastructure. + The command "opentf destroy" is a convenience alias for this option. -lock=false Don't hold a state lock during the operation. This is @@ -373,25 +373,25 @@ Options: state. If you don't provide a saved plan file then this command will also accept - all of the plan-customization options accepted by the terraform plan command. + all of the plan-customization options accepted by the opentf plan command. For more information on those options, run: - terraform plan -help + opentf plan -help ` return strings.TrimSpace(helpText) } func (c *ApplyCommand) helpDestroy() string { helpText := ` -Usage: terraform [global options] destroy [options] +Usage: opentf [global options] destroy [options] - Destroy Terraform-managed infrastructure. + Destroy OpenTF-managed infrastructure. This command is a convenience alias for: - terraform apply -destroy + opentf apply -destroy This command also accepts many of the plan-customization options accepted by - the terraform plan command. For more information on those options, run: - terraform plan -help + the opentf plan command. For more information on those options, run: + opentf plan -help ` return strings.TrimSpace(helpText) } diff --git a/internal/command/cloud.go b/internal/command/cloud.go index b8a8ebf7e9..53d50406d0 100644 --- a/internal/command/cloud.go +++ b/internal/command/cloud.go @@ -8,6 +8,7 @@ import ( "os/exec" "github.com/hashicorp/go-plugin" + "github.com/placeholderplaceholderplaceholder/opentf/internal/cloudplugin" "github.com/placeholderplaceholderplaceholder/opentf/internal/cloudplugin/cloudplugin1" "github.com/placeholderplaceholderplaceholder/opentf/internal/logging" @@ -73,7 +74,7 @@ func (c *CloudCommand) proxy(args []string, stdout, stderr io.Writer) int { // multiple versions are possible. cloud1, ok := raw.(cloudplugin.Cloud1) if !ok { - c.Ui.Error("If more than one cloudplugin versions are available, they need to be added to the cloud command. This is a bug in Terraform.") + c.Ui.Error("If more than one cloudplugin versions are available, they need to be added to the cloud command. This is a bug in OpenTF.") return ExitRPCError } return cloud1.Execute(args, stdout, stderr) diff --git a/internal/command/command.go b/internal/command/command.go index a18ef344d0..a9d779a811 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -44,7 +44,7 @@ const DefaultParallelism = 10 // that require a backend.Local. const ErrUnsupportedLocalOp = `The configured backend doesn't support this operation. -The "backend" in Terraform defines how Terraform operates. The default +The "backend" in OpenTF defines how OpenTF operates. The default backend performs all operations locally on your machine. Your configuration is configured to use a non-local backend. This backend doesn't support this operation. diff --git a/internal/command/console.go b/internal/command/console.go index 2c6a95caa8..7cab8ef402 100644 --- a/internal/command/console.go +++ b/internal/command/console.go @@ -192,9 +192,9 @@ func (c *ConsoleCommand) modePiped(session *repl.Session, ui cli.Ui) int { func (c *ConsoleCommand) Help() string { helpText := ` -Usage: terraform [global options] console [options] +Usage: opentf [global options] console [options] - Starts an interactive console for experimenting with Terraform + Starts an interactive console for experimenting with OpenTF interpolations. This will open an interactive console that you can use to type @@ -209,10 +209,10 @@ Options: -state=path Legacy option for the local backend only. See the local backend's documentation for more information. - -var 'foo=bar' Set a variable in the Terraform configuration. This + -var 'foo=bar' Set a variable in the OpenTF configuration. This flag can be set multiple times. - -var-file=foo Set variables in the Terraform configuration from + -var-file=foo Set variables in the OpenTF configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded. ` @@ -220,5 +220,5 @@ Options: } func (c *ConsoleCommand) Synopsis() string { - return "Try Terraform expressions at an interactive command prompt" + return "Try OpenTF expressions at an interactive command prompt" } diff --git a/internal/command/console_interactive_solaris.go b/internal/command/console_interactive_solaris.go index d8748ac6ca..922f722545 100644 --- a/internal/command/console_interactive_solaris.go +++ b/internal/command/console_interactive_solaris.go @@ -10,12 +10,13 @@ import ( "fmt" "github.com/mitchellh/cli" + "github.com/placeholderplaceholderplaceholder/opentf/internal/repl" ) func (c *ConsoleCommand) modeInteractive(session *repl.Session, ui cli.Ui) int { ui.Error(fmt.Sprintf( - "The readline library Terraform currently uses for the interactive\n" + + "The readline library OpenTF currently uses for the interactive\n" + "console is not supported by Solaris. Interactive mode is therefore\n" + "not supported on Solaris currently.")) return 1 diff --git a/internal/command/e2etest/init_test.go b/internal/command/e2etest/init_test.go index 50695f8bec..9ebfdd0cf0 100644 --- a/internal/command/e2etest/init_test.go +++ b/internal/command/e2etest/init_test.go @@ -39,7 +39,7 @@ func TestInitProviders(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Terraform has been successfully initialized!") { + if !strings.Contains(stdout, "OpenTF has been successfully initialized!") { t.Errorf("success message is missing from output:\n%s", stdout) } @@ -48,7 +48,7 @@ func TestInitProviders(t *testing.T) { t.Logf("(this can happen if you have a copy of the plugin in one of the global plugin search dirs)") } - if !strings.Contains(stdout, "Terraform has created a lock file") { + if !strings.Contains(stdout, "OpenTF has created a lock file") { t.Errorf("lock file notification is missing from output:\n%s", stdout) } @@ -72,7 +72,7 @@ func TestInitProvidersInternal(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Terraform has been successfully initialized!") { + if !strings.Contains(stdout, "OpenTF has been successfully initialized!") { t.Errorf("success message is missing from output:\n%s", stdout) } @@ -121,7 +121,7 @@ func TestInitProvidersVendored(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Terraform has been successfully initialized!") { + if !strings.Contains(stdout, "OpenTF has been successfully initialized!") { t.Errorf("success message is missing from output:\n%s", stdout) } @@ -170,7 +170,7 @@ func TestInitProvidersLocalOnly(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Terraform has been successfully initialized!") { + if !strings.Contains(stdout, "OpenTF has been successfully initialized!") { t.Errorf("success message is missing from output:\n%s", stdout) } @@ -218,7 +218,7 @@ func TestInitProvidersCustomMethod(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Terraform has been successfully initialized!") { + if !strings.Contains(stdout, "OpenTF has been successfully initialized!") { t.Errorf("success message is missing from output:\n%s", stdout) } @@ -379,7 +379,7 @@ func TestInitProviderNotFound(t *testing.T) { │ consumers will get the correct providers when using a module. To see which │ modules are currently depending on hashicorp/nonexist, run the following │ command: -│ terraform providers +│ opentf providers ╵ ` diff --git a/internal/command/e2etest/module_archive_test.go b/internal/command/e2etest/module_archive_test.go index 87754b934e..962d629dcc 100644 --- a/internal/command/e2etest/module_archive_test.go +++ b/internal/command/e2etest/module_archive_test.go @@ -29,7 +29,7 @@ func TestInitModuleArchive(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Terraform has been successfully initialized!") { + if !strings.Contains(stdout, "OpenTF has been successfully initialized!") { t.Errorf("success message is missing from output:\n%s", stdout) } } diff --git a/internal/command/e2etest/providers_tamper_test.go b/internal/command/e2etest/providers_tamper_test.go index 25fcb9e579..2770d1b886 100644 --- a/internal/command/e2etest/providers_tamper_test.go +++ b/internal/command/e2etest/providers_tamper_test.go @@ -69,7 +69,7 @@ func TestProviderTampering(t *testing.T) { if want := `registry.terraform.io/hashicorp/null: there is no package for registry.terraform.io/hashicorp/null 3.1.0 cached in ` + providerCacheDir; !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) } @@ -104,7 +104,7 @@ func TestProviderTampering(t *testing.T) { if want := `Initial configuration of the requested backend "local"`; !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) } @@ -134,7 +134,7 @@ func TestProviderTampering(t *testing.T) { if want := `registry.terraform.io/hashicorp/null: the cached package for registry.terraform.io/hashicorp/null 3.1.0 (in ` + providerCacheDir + `) does not match any of the checksums recorded in the dependency lock file`; !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) } }) diff --git a/internal/command/e2etest/version_test.go b/internal/command/e2etest/version_test.go index 3d7c95d94f..49462a9f47 100644 --- a/internal/command/e2etest/version_test.go +++ b/internal/command/e2etest/version_test.go @@ -33,7 +33,7 @@ func TestVersion(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - wantVersion := fmt.Sprintf("Terraform v%s", version.String()) + wantVersion := fmt.Sprintf("OpenTF v%s", version.String()) if !strings.Contains(stdout, wantVersion) { t.Errorf("output does not contain our current version %q:\n%s", wantVersion, stdout) } @@ -64,7 +64,7 @@ func TestVersionWithProvider(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - wantVersion := fmt.Sprintf("Terraform v%s", version.String()) + wantVersion := fmt.Sprintf("OpenTF v%s", version.String()) if !strings.Contains(stdout, wantVersion) { t.Errorf("output does not contain our current version %q:\n%s", wantVersion, stdout) } diff --git a/internal/command/fmt.go b/internal/command/fmt.go index 3fac2494d1..a475c748ee 100644 --- a/internal/command/fmt.go +++ b/internal/command/fmt.go @@ -159,7 +159,7 @@ func (c *FmtCommand) fmt(paths []string, stdin io.Reader, stdout io.Writer) tfdi } if !fmtd { - diags = diags.Append(fmt.Errorf("Only .tf, .tfvars, and .tftest.hcl files can be processed with terraform fmt")) + diags = diags.Append(fmt.Errorf("Only .tf, .tfvars, and .tftest.hcl files can be processed with opentf fmt")) continue } } @@ -171,7 +171,7 @@ func (c *FmtCommand) fmt(paths []string, stdin io.Reader, stdout io.Writer) tfdi func (c *FmtCommand) processFile(path string, r io.Reader, w io.Writer, isStdout bool) tfdiags.Diagnostics { var diags tfdiags.Diagnostics - log.Printf("[TRACE] terraform fmt: Formatting %s", path) + log.Printf("[TRACE] opentf fmt: Formatting %s", path) src, err := ioutil.ReadAll(r) if err != nil { @@ -229,7 +229,7 @@ func (c *FmtCommand) processFile(path string, r io.Reader, w io.Writer, isStdout func (c *FmtCommand) processDir(path string, stdout io.Writer) tfdiags.Diagnostics { var diags tfdiags.Diagnostics - log.Printf("[TRACE] terraform fmt: looking for files in %s", path) + log.Printf("[TRACE] opentf fmt: looking for files in %s", path) entries, err := ioutil.ReadDir(path) if err != nil { @@ -547,9 +547,9 @@ func (c *FmtCommand) trimNewlines(tokens hclwrite.Tokens) hclwrite.Tokens { func (c *FmtCommand) Help() string { helpText := ` -Usage: terraform [global options] fmt [options] [target...] +Usage: opentf [global options] fmt [options] [target...] - Rewrites all Terraform configuration files to a canonical format. All + Rewrites all OpenTF configuration files to a canonical format. All configuration files (.tf), variables files (.tfvars), and testing files (.tftest.hcl) are updated. JSON files (.tf.json, .tfvars.json, or .tftest.json) are not modified. @@ -560,7 +560,7 @@ Usage: terraform [global options] fmt [options] [target...] file. If you provide a single dash ("-"), then fmt will read from standard input (STDIN). - The content must be in the Terraform language native syntax; JSON is not + The content must be in the OpenTF language native syntax; JSON is not supported. Options: diff --git a/internal/command/get.go b/internal/command/get.go index 72d9ce3d47..50da9c6cec 100644 --- a/internal/command/get.go +++ b/internal/command/get.go @@ -54,7 +54,7 @@ func (c *GetCommand) Run(args []string) int { func (c *GetCommand) Help() string { helpText := ` -Usage: terraform [global options] get [options] +Usage: opentf [global options] get [options] Downloads and installs modules needed for the configuration in the current working directory. @@ -65,7 +65,7 @@ Usage: terraform [global options] get [options] unless the -update flag is specified. Module installation also happens automatically by default as part of - the "terraform init" command, so you should rarely need to run this + the "opentf init" command, so you should rarely need to run this command separately. Options: @@ -75,14 +75,14 @@ Options: -no-color Disable text coloring in the output. - -test-directory=path Set the Terraform test directory, defaults to "tests". + -test-directory=path Set the OpenTF test directory, defaults to "tests". ` return strings.TrimSpace(helpText) } func (c *GetCommand) Synopsis() string { - return "Install or upgrade remote Terraform modules" + return "Install or upgrade remote OpenTF modules" } func getModules(ctx context.Context, m *Meta, path string, testsDir string, upgrade bool) (abort bool, diags tfdiags.Diagnostics) { diff --git a/internal/command/graph.go b/internal/command/graph.go index b1205d3696..b52747954b 100644 --- a/internal/command/graph.go +++ b/internal/command/graph.go @@ -196,7 +196,7 @@ func (c *GraphCommand) Run(args []string) int { func (c *GraphCommand) Help() string { helpText := ` -Usage: terraform [global options] graph [options] +Usage: opentf [global options] graph [options] Produces a representation of the dependency graph between different objects in the current configuration and state. @@ -214,10 +214,10 @@ Options: This helps when diagnosing cycle errors. -type=plan Type of graph to output. Can be: plan, plan-refresh-only, - plan-destroy, or apply. By default Terraform chooses + plan-destroy, or apply. By default OpenTF chooses "plan", or "apply" if you also set the -plan=... option. - -module-depth=n (deprecated) In prior versions of Terraform, specified the + -module-depth=n (deprecated) In prior versions of OpenTF, specified the depth of modules to show in the output. ` return strings.TrimSpace(helpText) diff --git a/internal/command/helper.go b/internal/command/helper.go index 604d638bd7..07b4007b14 100644 --- a/internal/command/helper.go +++ b/internal/command/helper.go @@ -11,17 +11,17 @@ import ( const failedToLoadSchemasMessage = ` Warning: Failed to update data for external integrations -Terraform was unable to generate a description of the updated +OpenTF was unable to generate a description of the updated state for use with external integrations in Terraform Cloud. Any integrations configured for this workspace which depend on information from the state may not work correctly when using the result of this action. -This problem occurs when Terraform cannot read the schema for +This problem occurs when OpenTF cannot read the schema for one or more of the providers used in the state. The next successful apply will correct the problem by re-generating the JSON description of the state: - terraform apply + opentf apply ` func isCloudMode(b backend.Enhanced) bool { diff --git a/internal/command/import.go b/internal/command/import.go index d6fc14f0a3..a1786592d0 100644 --- a/internal/command/import.go +++ b/internal/command/import.go @@ -41,7 +41,7 @@ func (c *ImportCommand) Run(args []string) int { args = c.Meta.process(args) cmdFlags := c.Meta.extendedFlagSet("import") - cmdFlags.BoolVar(&c.ignoreRemoteVersion, "ignore-remote-version", false, "continue even if remote and local Terraform versions are incompatible") + cmdFlags.BoolVar(&c.ignoreRemoteVersion, "ignore-remote-version", false, "continue even if remote and local OpenTF versions are incompatible") cmdFlags.IntVar(&c.Meta.parallelism, "parallelism", DefaultParallelism, "parallelism") cmdFlags.StringVar(&c.Meta.statePath, "state", "", "path") cmdFlags.StringVar(&c.Meta.stateOutPath, "state-out", "", "path") @@ -91,9 +91,9 @@ func (c *ImportCommand) Run(args []string) int { if !c.dirIsConfigPath(configPath) { diags = diags.Append(&hcl.Diagnostic{ Severity: hcl.DiagError, - Summary: "No Terraform configuration files", + Summary: "No OpenTF configuration files", Detail: fmt.Sprintf( - "The directory %s does not contain any Terraform configuration files (.tf or .tf.json). To specify a different configuration directory, use the -config=\"...\" command line option.", + "The directory %s does not contain any OpenTF configuration files (.tf or .tf.json). To specify a different configuration directory, use the -config=\"...\" command line option.", configPath, ), }) @@ -286,13 +286,13 @@ func (c *ImportCommand) Run(args []string) int { func (c *ImportCommand) Help() string { helpText := ` -Usage: terraform [global options] import [options] ADDR ID +Usage: opentf [global options] import [options] ADDR ID - Import existing infrastructure into your Terraform state. + Import existing infrastructure into your OpenTF state. - This will find and import the specified resource into your Terraform - state, allowing existing infrastructure to come under Terraform - management without having to be initially created by Terraform. + This will find and import the specified resource into your OpenTF + state, allowing existing infrastructure to come under OpenTF + management without having to be initially created by OpenTF. The ADDR specified is the address to import the resource to. Please see the documentation online for resource addresses. The ID is a @@ -307,7 +307,7 @@ Usage: terraform [global options] import [options] ADDR ID Options: - -config=path Path to a directory of Terraform configuration files + -config=path Path to a directory of OpenTF configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars. @@ -322,11 +322,11 @@ Options: -no-color If specified, output won't contain any color. - -var 'foo=bar' Set a variable in the Terraform configuration. This + -var 'foo=bar' Set a variable in the OpenTF configuration. This flag can be set multiple times. This is only useful with the "-config" flag. - -var-file=foo Set variables in the Terraform configuration from + -var-file=foo Set variables in the OpenTF configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded. @@ -341,7 +341,7 @@ Options: } func (c *ImportCommand) Synopsis() string { - return "Associate existing infrastructure with a Terraform resource" + return "Associate existing infrastructure with a OpenTF resource" } const importCommandInvalidAddressReference = `For information on valid syntax, see: @@ -359,5 +359,5 @@ resource %q %q { const importCommandSuccessMsg = `Import successful! The resources that were imported are shown above. These resources are now in -your Terraform state and will henceforth be managed by Terraform. +your OpenTF state and will henceforth be managed by OpenTF. ` diff --git a/internal/command/import_test.go b/internal/command/import_test.go index ec56e0ff1e..762a51838b 100644 --- a/internal/command/import_test.go +++ b/internal/command/import_test.go @@ -189,7 +189,7 @@ func TestImport_remoteState(t *testing.T) { } // (Using log here rather than t.Log so that these messages interleave with other trace logs) - log.Print("[TRACE] TestImport_remoteState running: terraform init") + log.Print("[TRACE] TestImport_remoteState running: opentf init") if code := ic.Run([]string{}); code != 0 { t.Fatalf("init failed\n%s", ui.ErrorWriter) } @@ -250,7 +250,7 @@ func TestImport_remoteState(t *testing.T) { "test_instance.foo", "bar", } - log.Printf("[TRACE] TestImport_remoteState running: terraform import %s %s", args[0], args[1]) + log.Printf("[TRACE] TestImport_remoteState running: opentf import %s %s", args[0], args[1]) if code := c.Run(args); code != 0 { fmt.Println(ui.OutputWriter) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) @@ -301,7 +301,7 @@ func TestImport_initializationErrorShouldUnlock(t *testing.T) { } // (Using log here rather than t.Log so that these messages interleave with other trace logs) - log.Print("[TRACE] TestImport_initializationErrorShouldUnlock running: terraform init") + log.Print("[TRACE] TestImport_initializationErrorShouldUnlock running: opentf init") if code := ic.Run([]string{}); code != 0 { t.Fatalf("init failed\n%s", ui.ErrorWriter) } @@ -323,7 +323,7 @@ func TestImport_initializationErrorShouldUnlock(t *testing.T) { "unknown_instance.baz", "bar", } - log.Printf("[TRACE] TestImport_initializationErrorShouldUnlock running: terraform import %s %s", args[0], args[1]) + log.Printf("[TRACE] TestImport_initializationErrorShouldUnlock running: opentf import %s %s", args[0], args[1]) // this should fail if code := c.Run(args); code != 1 { @@ -674,7 +674,7 @@ func TestImport_emptyConfig(t *testing.T) { } msg := ui.ErrorWriter.String() - if want := `No Terraform configuration files`; !strings.Contains(msg, want) { + if want := `No OpenTF configuration files`; !strings.Contains(msg, want) { t.Errorf("incorrect message\nwant substring: %s\ngot:\n%s", want, msg) } } diff --git a/internal/command/init.go b/internal/command/init.go index 37e9c143c1..79ef1c408a 100644 --- a/internal/command/init.go +++ b/internal/command/init.go @@ -61,7 +61,7 @@ func (c *InitCommand) Run(args []string) int { cmdFlags.BoolVar(&flagUpgrade, "upgrade", false, "") cmdFlags.Var(&flagPluginPath, "plugin-dir", "plugin directory") cmdFlags.StringVar(&flagLockfile, "lockfile", "", "Set a dependency lockfile mode") - cmdFlags.BoolVar(&c.Meta.ignoreRemoteVersion, "ignore-remote-version", false, "continue even if remote and local Terraform versions are incompatible") + cmdFlags.BoolVar(&c.Meta.ignoreRemoteVersion, "ignore-remote-version", false, "continue even if remote and local OpenTF versions are incompatible") cmdFlags.StringVar(&testsDirectory, "test-directory", "tests", "test-directory") cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } if err := cmdFlags.Parse(args); err != nil { @@ -390,7 +390,7 @@ func (c *InitCommand) getModules(ctx context.Context, path, testsDir string, ear diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to read module manifest", - fmt.Sprintf("After installing modules, Terraform could not re-read the manifest of installed modules. This is a bug in Terraform. %s.", err), + fmt.Sprintf("After installing modules, OpenTF could not re-read the manifest of installed modules. This is a bug in OpenTF. %s.", err), )) } } @@ -592,7 +592,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, c.Ui.Info(fmt.Sprintf("- Using previously-installed %s v%s", provider.ForDisplay(), selectedVersion)) }, BuiltInProviderAvailable: func(provider addrs.Provider) { - c.Ui.Info(fmt.Sprintf("- %s is built in to Terraform", provider.ForDisplay())) + c.Ui.Info(fmt.Sprintf("- %s is built in to OpenTF", provider.ForDisplay())) }, BuiltInProviderFailure: func(provider addrs.Provider, err error) { diags = diags.Append(tfdiags.Sourceless( @@ -636,11 +636,11 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, case getproviders.ErrRegistryProviderNotKnown: // We might be able to suggest an alternative provider to use // instead of this one. - suggestion := fmt.Sprintf("\n\nAll modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on %s, run the following command:\n terraform providers", provider.ForDisplay()) + suggestion := fmt.Sprintf("\n\nAll modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on %s, run the following command:\n opentf providers", provider.ForDisplay()) alternative := getproviders.MissingProviderSuggestion(ctx, provider, inst.ProviderSource(), reqs) if alternative != provider { suggestion = fmt.Sprintf( - "\n\nDid you intend to use %s? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on %s, run the following command:\n terraform providers", + "\n\nDid you intend to use %s? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on %s, run the following command:\n opentf providers", alternative.ForDisplay(), provider.ForDisplay(), ) } @@ -666,7 +666,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Invalid provider registry host", - fmt.Sprintf("The given source address %q specifies a GitHub repository rather than a Terraform provider. Refer to the documentation of the provider to find the correct source address to use.", + fmt.Sprintf("The given source address %q specifies a GitHub repository rather than a OpenTF provider. Refer to the documentation of the provider to find the correct source address to use.", provider.String(), ), )) @@ -675,7 +675,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Invalid provider registry host", - fmt.Sprintf("The host %q given in provider source address %q does not offer a Terraform provider registry that is compatible with this Terraform version, but it may be compatible with a different Terraform version.", + fmt.Sprintf("The host %q given in provider source address %q does not offer a OpenTF provider registry that is compatible with this OpenTF version, but it may be compatible with a different OpenTF version.", errorTy.Hostname, provider.String(), ), )) @@ -684,7 +684,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Invalid provider registry host", - fmt.Sprintf("The host %q given in provider source address %q does not offer a Terraform provider registry.", + fmt.Sprintf("The host %q given in provider source address %q does not offer a OpenTF provider registry.", errorTy.Hostname, provider.String(), ), )) @@ -769,7 +769,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, tfdiags.Error, summaryIncompatible, fmt.Sprintf( - "Your chosen provider mirror at %s does not have a %s v%s package available for your current platform, %s.\n\nProvider releases are separate from Terraform CLI releases, so this provider might not support your current platform. Alternatively, the mirror itself might have only a subset of the plugin packages available in the origin registry, at %s.", + "Your chosen provider mirror at %s does not have a %s v%s package available for your current platform, %s.\n\nProvider releases are separate from OpenTF CLI releases, so this provider might not support your current platform. Alternatively, the mirror itself might have only a subset of the plugin packages available in the origin registry, at %s.", err.MirrorURL, err.Provider, err.Version, err.Platform, err.Provider.Hostname, ), @@ -779,7 +779,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, tfdiags.Error, summaryIncompatible, fmt.Sprintf( - "Provider %s v%s does not have a package available for your current platform, %s.\n\nProvider releases are separate from Terraform CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms supported.", + "Provider %s v%s does not have a package available for your current platform, %s.\n\nProvider releases are separate from OpenTF CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms supported.", err.Provider, err.Version, err.Platform, ), )) @@ -911,7 +911,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, `Provider dependency changes detected`, - `Changes to the required provider dependencies were detected, but the lock file is read-only. To use and record these requirements, run "terraform init" without the "-lockfile=readonly" flag.`, + `Changes to the required provider dependencies were detected, but the lock file is read-only. To use and record these requirements, run "opentf init" without the "-lockfile=readonly" flag.`, )) return true, true, diags } @@ -921,7 +921,7 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, diags = diags.Append(tfdiags.Sourceless( tfdiags.Warning, `Provider lock file not updated`, - `Changes to the provider selections were detected, but not saved in the .terraform.lock.hcl file. To record these selections, run "terraform init" without the "-lockfile=readonly" flag.`, + `Changes to the provider selections were detected, but not saved in the .terraform.lock.hcl file. To record these selections, run "opentf init" without the "-lockfile=readonly" flag.`, )) return true, false, diags } @@ -950,13 +950,13 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, // users or those who are upgrading from a previous Terraform // version that didn't have dependency lock files. c.Ui.Output(c.Colorize().Color(` -Terraform has created a lock file [bold].terraform.lock.hcl[reset] to record the provider +OpenTF has created a lock file [bold].terraform.lock.hcl[reset] to record the provider selections it made above. Include this file in your version control repository -so that Terraform can guarantee to make the same selections by default when -you run "terraform init" in the future.`)) +so that OpenTF can guarantee to make the same selections by default when +you run "opentf init" in the future.`)) } else { c.Ui.Output(c.Colorize().Color(` -Terraform has made some changes to the provider dependency selections recorded +OpenTF has made some changes to the provider dependency selections recorded in the .terraform.lock.hcl file. Review those changes and commit them to your version control system if they represent changes you intended to make.`)) } @@ -1098,14 +1098,14 @@ func (c *InitCommand) AutocompleteFlags() complete.Flags { func (c *InitCommand) Help() string { helpText := ` -Usage: terraform [global options] init [options] +Usage: opentf [global options] init [options] - Initialize a new or existing Terraform working directory by creating + Initialize a new or existing OpenTF working directory by creating initial files, loading any remote state, downloading modules, etc. This is the first command that should be run for any new or existing - Terraform configuration per machine. This sets up all the local data - necessary to run Terraform that is typically not committed to version + OpenTF configuration per machine. This sets up all the local data + necessary to run OpenTF that is typically not committed to version control. This command is always safe to run multiple times. Though subsequent runs @@ -1172,12 +1172,12 @@ Options: -ignore-remote-version A rare option used for Terraform Cloud and the remote backend only. Set this to ignore checking that the local and remote - Terraform versions use compatible state representations, making + OpenTF versions use compatible state representations, making an operation proceed even when there is a potential mismatch. - See the documentation on configuring Terraform with + See the documentation on configuring OpenTF with Terraform Cloud for more information. - -test-directory=path Set the Terraform test directory, defaults to "tests". + -test-directory=path Set the OpenTF test directory, defaults to "tests". ` return strings.TrimSpace(helpText) @@ -1188,11 +1188,11 @@ func (c *InitCommand) Synopsis() string { } const errInitConfigError = ` -[reset]Terraform encountered problems during initialisation, including problems +[reset]OpenTF encountered problems during initialisation, including problems with the configuration, described below. -The Terraform configuration must be valid before initialization so that -Terraform can determine which modules and providers need to be installed. +The OpenTF configuration must be valid before initialization so that +OpenTF can determine which modules and providers need to be installed. ` const errInitCopyNotEmpty = ` @@ -1204,14 +1204,14 @@ To initialize the configuration already in this working directory, omit the ` const outputInitEmpty = ` -[reset][bold]Terraform initialized in an empty directory![reset] +[reset][bold]OpenTF initialized in an empty directory![reset] -The directory has no Terraform configuration files. You may begin working -with Terraform immediately by creating Terraform configuration files. +The directory has no OpenTF configuration files. You may begin working +with OpenTF immediately by creating OpenTF configuration files. ` const outputInitSuccess = ` -[reset][bold][green]Terraform has been successfully initialized![reset][green] +[reset][bold][green]OpenTF has been successfully initialized![reset][green] ` const outputInitSuccessCloud = ` @@ -1219,49 +1219,49 @@ const outputInitSuccessCloud = ` ` const outputInitSuccessCLI = `[reset][green] -You may now begin working with Terraform. Try running "terraform plan" to see -any changes that are required for your infrastructure. All Terraform commands +You may now begin working with OpenTF. Try running "opentf plan" to see +any changes that are required for your infrastructure. All OpenTF commands should now work. -If you ever set or change modules or backend configuration for Terraform, +If you ever set or change modules or backend configuration for OpenTF, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. ` const outputInitSuccessCLICloud = `[reset][green] -You may now begin working with Terraform Cloud. Try running "terraform plan" to +You may now begin working with Terraform Cloud. Try running "opentf plan" to see any changes that are required for your infrastructure. -If you ever set or change modules or Terraform Settings, run "terraform init" +If you ever set or change modules or OpenTF Settings, run "opentf init" 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, // but a newer version of the provider is compatible. -const providerProtocolTooOld = `Provider %q v%s is not compatible with Terraform %s. +const providerProtocolTooOld = `Provider %q v%s is not compatible with OpenTF %s. Provider version %s is the latest compatible version. Select it with the following version constraint: version = %q -Terraform checked all of the plugin versions matching the given constraint: +OpenTF checked all of the plugin versions matching the given constraint: %s -Consult the documentation for this provider for more information on compatibility between provider and Terraform versions. +Consult the documentation for this provider for more information on compatibility between provider and OpenTF versions. ` // 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 // provider. -const providerProtocolTooNew = `Provider %q v%s is not compatible with Terraform %s. +const providerProtocolTooNew = `Provider %q v%s is not compatible with OpenTF %s. You need to downgrade to v%s or earlier. Select it with the following constraint: version = %q -Terraform checked all of the plugin versions matching the given constraint: +OpenTF checked all of the plugin versions matching the given constraint: %s -Consult the documentation for this provider for more information on compatibility between provider and Terraform versions. -Alternatively, upgrade to the latest version of Terraform for compatibility with newer provider releases. +Consult the documentation for this provider for more information on compatibility between provider and OpenTF versions. +Alternatively, upgrade to the latest version of OpenTF for compatibility with newer provider releases. ` // No version of the provider is compatible. @@ -1273,11 +1273,11 @@ const incompleteLockFileInformationHeader = `Incomplete lock file information fo // incompleteLockFileInformationBody is the body of text displayed to users when // the lock file has only recorded local hashes. -const incompleteLockFileInformationBody = `Due to your customized provider installation methods, Terraform was forced to calculate lock file checksums locally for the following providers: +const incompleteLockFileInformationBody = `Due to your customized provider installation methods, OpenTF was forced to calculate lock file checksums locally for the following providers: - %s -The current .terraform.lock.hcl file only includes checksums for %s, so Terraform running on another platform will fail to install these providers. +The current .terraform.lock.hcl file only includes checksums for %s, so OpenTF running on another platform will fail to install these providers. To calculate additional checksums for another platform, run: - terraform providers lock -platform=linux_amd64 + opentf providers lock -platform=linux_amd64 (where linux_amd64 is the platform to generate)` diff --git a/internal/command/init_test.go b/internal/command/init_test.go index 596ec66858..57f90b5576 100644 --- a/internal/command/init_test.go +++ b/internal/command/init_test.go @@ -1663,7 +1663,7 @@ func TestInit_providerSource(t *testing.T) { if code := c.Run(args); code != 0 { t.Fatalf("bad: \n%s", ui.ErrorWriter.String()) } - if strings.Contains(ui.OutputWriter.String(), "Terraform has initialized, but configuration upgrades may be needed") { + if strings.Contains(ui.OutputWriter.String(), "OpenTF has initialized, but configuration upgrades may be needed") { t.Fatalf("unexpected \"configuration upgrade\" warning in output") } @@ -2576,8 +2576,8 @@ func TestInit_pluginDirWithBuiltIn(t *testing.T) { } outputStr := ui.OutputWriter.String() - if subStr := "terraform.io/builtin/terraform is built in to Terraform"; !strings.Contains(outputStr, subStr) { - t.Errorf("output should mention the terraform provider\nwant substr: %s\ngot:\n%s", subStr, outputStr) + if subStr := "terraform.io/builtin/terraform is built in to OpenTF"; !strings.Contains(outputStr, subStr) { + t.Errorf("output should mention the opentf provider\nwant substr: %s\ngot:\n%s", subStr, outputStr) } } @@ -2642,7 +2642,7 @@ func TestInit_invalidSyntaxNoBackend(t *testing.T) { } errStr := ui.ErrorWriter.String() - if subStr := "Terraform encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { + if subStr := "OpenTF encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { t.Errorf("Error output should include preamble\nwant substr: %s\ngot:\n%s", subStr, errStr) } if subStr := "Error: Unsupported block type"; !strings.Contains(errStr, subStr) { @@ -2671,7 +2671,7 @@ func TestInit_invalidSyntaxWithBackend(t *testing.T) { } errStr := ui.ErrorWriter.String() - if subStr := "Terraform encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { + if subStr := "OpenTF encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { t.Errorf("Error output should include preamble\nwant substr: %s\ngot:\n%s", subStr, errStr) } if subStr := "Error: Unsupported block type"; !strings.Contains(errStr, subStr) { @@ -2700,7 +2700,7 @@ func TestInit_invalidSyntaxInvalidBackend(t *testing.T) { } errStr := ui.ErrorWriter.String() - if subStr := "Terraform encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { + if subStr := "OpenTF encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { t.Errorf("Error output should include preamble\nwant substr: %s\ngot:\n%s", subStr, errStr) } if subStr := "Error: Unsupported block type"; !strings.Contains(errStr, subStr) { @@ -2732,7 +2732,7 @@ func TestInit_invalidSyntaxBackendAttribute(t *testing.T) { } errStr := ui.ErrorWriter.String() - if subStr := "Terraform encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { + if subStr := "OpenTF encountered problems during initialisation, including problems\nwith the configuration, described below."; !strings.Contains(errStr, subStr) { t.Errorf("Error output should include preamble\nwant substr: %s\ngot:\n%s", subStr, errStr) } if subStr := "Error: Invalid character"; !strings.Contains(errStr, subStr) { diff --git a/internal/command/login.go b/internal/command/login.go index d24f027393..7069f6b3cb 100644 --- a/internal/command/login.go +++ b/internal/command/login.go @@ -23,6 +23,7 @@ import ( svchost "github.com/hashicorp/terraform-svchost" svcauth "github.com/hashicorp/terraform-svchost/auth" "github.com/hashicorp/terraform-svchost/disco" + "github.com/placeholderplaceholderplaceholder/opentf/internal/command/cliconfig" "github.com/placeholderplaceholderplaceholder/opentf/internal/httpclient" "github.com/placeholderplaceholderplaceholder/opentf/internal/logging" @@ -63,7 +64,7 @@ func (c *LoginCommand) Run(args []string) int { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Login is an interactive command", - "The \"terraform login\" command uses interactive prompts to obtain and record credentials, so it can't be run with input disabled.\n\nTo configure credentials in a non-interactive context, write existing credentials directly to a CLI configuration file.", + "The \"opentf login\" command uses interactive prompts to obtain and record credentials, so it can't be run with input disabled.\n\nTo configure credentials in a non-interactive context, write existing credentials directly to a CLI configuration file.", )) c.showDiagnostics(diags) return 1 @@ -125,14 +126,14 @@ func (c *LoginCommand) Run(args []string) int { case *disco.ErrVersionNotSupported: diags = diags.Append(tfdiags.Sourceless( tfdiags.Warning, - "Host does not support Terraform login", - fmt.Sprintf("The given hostname %q allows creating Terraform authorization tokens, but requires a newer version of Terraform CLI to do so.", dispHostname), + "Host does not support OpenTF login", + fmt.Sprintf("The given hostname %q allows creating OpenTF authorization tokens, but requires a newer version of OpenTF CLI to do so.", dispHostname), )) default: diags = diags.Append(tfdiags.Sourceless( tfdiags.Warning, - "Host does not support Terraform login", - fmt.Sprintf("The given hostname %q cannot support \"terraform login\": %s.", dispHostname, err), + "Host does not support OpenTF login", + fmt.Sprintf("The given hostname %q cannot support \"opentf login\": %s.", dispHostname, err), )) } @@ -146,20 +147,20 @@ func (c *LoginCommand) Run(args []string) int { case *disco.ErrServiceNotProvided: diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, - "Host does not support Terraform tokens API", - fmt.Sprintf("The given hostname %q does not support creating Terraform authorization tokens.", dispHostname), + "Host does not support OpenTF tokens API", + fmt.Sprintf("The given hostname %q does not support creating OpenTF authorization tokens.", dispHostname), )) case *disco.ErrVersionNotSupported: diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, - "Host does not support Terraform tokens API", - fmt.Sprintf("The given hostname %q allows creating Terraform authorization tokens, but requires a newer version of Terraform CLI to do so.", dispHostname), + "Host does not support OpenTF tokens API", + fmt.Sprintf("The given hostname %q allows creating OpenTF authorization tokens, but requires a newer version of OpenTF CLI to do so.", dispHostname), )) default: diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, - "Host does not support Terraform tokens API", - fmt.Sprintf("The given hostname %q cannot support \"terraform login\": %s.", dispHostname, err), + "Host does not support OpenTF tokens API", + fmt.Sprintf("The given hostname %q cannot support \"opentf login\": %s.", dispHostname, err), )) } } @@ -168,7 +169,7 @@ func (c *LoginCommand) Run(args []string) int { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, fmt.Sprintf("Credentials for %s are manually configured", dispHostname), - "The \"terraform login\" command cannot log in because credentials for this host are already configured in a CLI configuration file.\n\nTo log in, first revoke the existing credentials and remove that block from the CLI configuration.", + "The \"opentf login\" command cannot log in because credentials for this host are already configured in a CLI configuration file.\n\nTo log in, first revoke the existing credentials and remove that block from the CLI configuration.", )) } @@ -180,7 +181,7 @@ func (c *LoginCommand) Run(args []string) int { var token svcauth.HostCredentialsToken var tokenDiags tfdiags.Diagnostics - // Prefer Terraform login if available + // Prefer OpenTF login if available if clientConfig != nil { var oauthToken *oauth2.Token @@ -196,8 +197,8 @@ func (c *LoginCommand) Run(args []string) int { default: tokenDiags = tokenDiags.Append(tfdiags.Sourceless( tfdiags.Error, - "Host does not support Terraform login", - fmt.Sprintf("The given hostname %q does not allow any OAuth grant types that are supported by this version of Terraform.", dispHostname), + "Host does not support OpenTF login", + fmt.Sprintf("The given hostname %q does not allow any OAuth grant types that are supported by this version of OpenTF.", dispHostname), )) } if oauthToken != nil { @@ -218,7 +219,7 @@ func (c *LoginCommand) Run(args []string) int { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to save API token", - fmt.Sprintf("The given host returned an API token, but Terraform failed to save it: %s.", err), + fmt.Sprintf("The given host returned an API token, but OpenTF failed to save it: %s.", err), )) } @@ -290,9 +291,9 @@ func (c *LoginCommand) Run(args []string) int { c.Ui.Output( fmt.Sprintf( c.Colorize().Color(strings.TrimSpace(` -[green][bold]Success![reset] [bold]Terraform has obtained and saved an API token.[reset] +[green][bold]Success![reset] [bold]OpenTF has obtained and saved an API token.[reset] -The new API token will be used for any future Terraform command that must make +The new API token will be used for any future OpenTF command that must make authenticated requests to %s. `)), dispHostname, @@ -338,7 +339,7 @@ func (c *LoginCommand) Help() string { } helpText := fmt.Sprintf(` -Usage: terraform [global options] login [hostname] +Usage: opentf [global options] login [hostname] Retrieves an authentication token for the given hostname, if it supports automatic login, and saves it in a credentials file in your home directory. @@ -486,7 +487,7 @@ func (c *LoginCommand) interactiveGetTokenByCode(hostname svchost.Hostname, cred if c.BrowserLauncher != nil { err = c.BrowserLauncher.OpenURL(authCodeURL) if err == nil { - c.Ui.Output(fmt.Sprintf("Terraform must now open a web browser to the login page for %s.\n", hostname.ForDisplay())) + c.Ui.Output(fmt.Sprintf("OpenTF must now open a web browser to the login page for %s.\n", hostname.ForDisplay())) c.Ui.Output(fmt.Sprintf("If a browser does not open this automatically, open the following URL to proceed:\n %s\n", authCodeURL)) } else { // Assume we're on a platform where opening a browser isn't possible. @@ -500,7 +501,7 @@ func (c *LoginCommand) interactiveGetTokenByCode(hostname svchost.Hostname, cred c.Ui.Output(fmt.Sprintf("Open the following URL to access the login page for %s:\n %s\n", hostname.ForDisplay(), authCodeURL)) } - c.Ui.Output("Terraform will now wait for the host to signal that login was successful.\n") + c.Ui.Output("OpenTF will now wait for the host to signal that login was successful.\n") code, ok := <-codeCh if !ok { @@ -543,7 +544,7 @@ func (c *LoginCommand) interactiveGetTokenByPassword(hostname svchost.Hostname, } c.Ui.Output("\n---------------------------------------------------------------------------------\n") - c.Ui.Output("Terraform must temporarily use your password to request an API token.\nThis password will NOT be saved locally.\n") + c.Ui.Output("OpenTF must temporarily use your password to request an API token.\nThis password will NOT be saved locally.\n") username, err := c.UIInput().Input(context.Background(), &terraform.InputOpts{ Id: "username", @@ -607,7 +608,7 @@ func (c *LoginCommand) interactiveGetTokenByUI(hostname svchost.Hostname, credsC if c.BrowserLauncher != nil { err := c.BrowserLauncher.OpenURL(tokensURL.String()) if err == nil { - c.Ui.Output(fmt.Sprintf("Terraform must now open a web browser to the tokens page for %s.\n", hostname.ForDisplay())) + c.Ui.Output(fmt.Sprintf("OpenTF must now open a web browser to the tokens page for %s.\n", hostname.ForDisplay())) c.Ui.Output(fmt.Sprintf("If a browser does not open this automatically, open the following URL to proceed:\n %s\n", tokensURL.String())) } else { log.Printf("[DEBUG] error opening web browser: %s", err) @@ -630,9 +631,9 @@ func (c *LoginCommand) interactiveGetTokenByUI(hostname svchost.Hostname, credsC if credsCtx != nil { switch credsCtx.Location { case cliconfig.CredentialsViaHelper: - c.Ui.Output(fmt.Sprintf("Terraform will store the token in the configured %q credentials helper\nfor use by subsequent commands.\n", credsCtx.HelperType)) + c.Ui.Output(fmt.Sprintf("OpenTF will store the token in the configured %q credentials helper\nfor use by subsequent commands.\n", credsCtx.HelperType)) case cliconfig.CredentialsInPrimaryFile, cliconfig.CredentialsNotAvailable: - c.Ui.Output(fmt.Sprintf("Terraform will store the token in plain text in the following file\nfor use by subsequent commands:\n %s\n", credsCtx.LocalFilename)) + c.Ui.Output(fmt.Sprintf("OpenTF will store the token in plain text in the following file\nfor use by subsequent commands:\n %s\n", credsCtx.LocalFilename)) } } @@ -678,7 +679,7 @@ func (c *LoginCommand) interactiveContextConsent(hostname svchost.Hostname, gran mechanism = "your browser" } - c.Ui.Output(fmt.Sprintf("Terraform will request an API token for %s using %s.\n", hostname.ForDisplay(), mechanism)) + c.Ui.Output(fmt.Sprintf("OpenTF will request an API token for %s using %s.\n", hostname.ForDisplay(), mechanism)) if grantType.UsesAuthorizationEndpoint() { c.Ui.Output( @@ -691,9 +692,9 @@ func (c *LoginCommand) interactiveContextConsent(hostname svchost.Hostname, gran if credsCtx != nil { switch credsCtx.Location { case cliconfig.CredentialsViaHelper: - c.Ui.Output(fmt.Sprintf("If login is successful, Terraform will store the token in the configured\n%q credentials helper for use by subsequent commands.\n", credsCtx.HelperType)) + c.Ui.Output(fmt.Sprintf("If login is successful, OpenTF will store the token in the configured\n%q credentials helper for use by subsequent commands.\n", credsCtx.HelperType)) case cliconfig.CredentialsInPrimaryFile, cliconfig.CredentialsNotAvailable: - c.Ui.Output(fmt.Sprintf("If login is successful, Terraform will store the token in plain text in\nthe following file for use by subsequent commands:\n %s\n", credsCtx.LocalFilename)) + c.Ui.Output(fmt.Sprintf("If login is successful, OpenTF will store the token in plain text in\nthe following file for use by subsequent commands:\n %s\n", credsCtx.LocalFilename)) } } @@ -783,7 +784,7 @@ type loginCredentialsContext struct { const callbackSuccessMessage = ` -Terraform Login +OpenTF Login