From 14260a5b4cd293d4a0ffae947ebb13c7173803cf Mon Sep 17 00:00:00 2001 From: Chris Arcand Date: Thu, 28 Oct 2021 10:37:06 -0500 Subject: [PATCH] Adjust default workspace naming prompt The previous version is a little overdramatic and somewhat accusatory. Just lay it out how it is: TFC needs workspaces to be named. --- internal/cloud/e2e/migrate_state_multi_to_tfc_test.go | 2 +- .../cloud/e2e/migrate_state_remote_backend_to_tfc_test.go | 4 ++-- internal/cloud/e2e/migrate_state_single_to_tfc_test.go | 2 +- internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go | 4 ++-- internal/command/meta_backend_migrate.go | 5 ++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/cloud/e2e/migrate_state_multi_to_tfc_test.go b/internal/cloud/e2e/migrate_state_multi_to_tfc_test.go index 6fda558f3..a0a6b7430 100644 --- a/internal/cloud/e2e/migrate_state_multi_to_tfc_test.go +++ b/internal/cloud/e2e/migrate_state_multi_to_tfc_test.go @@ -307,7 +307,7 @@ func Test_migrate_multi_to_tfc_cloud_tags_strategy(t *testing.T) { commands: []tfCommand{ { command: []string{"init", "-migrate-state"}, - expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`, + expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`, userInput: []string{"dev", "1", "app-*", "1"}, postInputOutput: []string{ `Would you like to rename your workspaces?`, diff --git a/internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go b/internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go index c9fe01976..7f0a6fbc8 100644 --- a/internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go +++ b/internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go @@ -379,7 +379,7 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) { commands: []tfCommand{ { command: []string{"init", "-migrate-state", "-ignore-remote-version"}, - expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`, + expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`, userInput: []string{"cloud-workspace", "yes"}, postInputOutput: []string{ `Do you want to copy existing state to Terraform Cloud?`, @@ -741,7 +741,7 @@ func Test_migrate_remote_backend_prefix_to_tfc_tags(t *testing.T) { commands: []tfCommand{ { command: []string{"init", "-migrate-state", "-ignore-remote-version"}, - expectedCmdOutput: `The Terraform Cloud configuration only allows named workspaces!`, + expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`, userInput: []string{"cloud-workspace", "yes"}, postInputOutput: []string{ `Do you want to copy existing state to Terraform Cloud?`, diff --git a/internal/cloud/e2e/migrate_state_single_to_tfc_test.go b/internal/cloud/e2e/migrate_state_single_to_tfc_test.go index c060ee63e..baf9126f4 100644 --- a/internal/cloud/e2e/migrate_state_single_to_tfc_test.go +++ b/internal/cloud/e2e/migrate_state_single_to_tfc_test.go @@ -103,7 +103,7 @@ func Test_migrate_single_to_tfc(t *testing.T) { commands: []tfCommand{ { command: []string{"init", "-migrate-state"}, - expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`, + expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`, userInput: []string{"new-workspace", "yes"}, postInputOutput: []string{ `Do you want to copy existing state to Terraform Cloud?`, diff --git a/internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go b/internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go index 6d086de5b..fff9b5416 100644 --- a/internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go +++ b/internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go @@ -134,7 +134,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) { commands: []tfCommand{ { command: []string{"init", "-migrate-state", "-ignore-remote-version"}, - expectedCmdOutput: `The Terraform Cloud configuration only allows named workspaces!`, + expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`, userInput: []string{"new-workspace", "yes"}, postInputOutput: []string{ `Do you want to copy existing state to Terraform Cloud?`, @@ -205,7 +205,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) { commands: []tfCommand{ { command: []string{"init", "-migrate-state"}, - expectedCmdOutput: `The Terraform Cloud configuration only allows named workspaces!`, + expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`, expectError: true, userInput: []string{"new-workspace", "yes"}, }, diff --git a/internal/command/meta_backend_migrate.go b/internal/command/meta_backend_migrate.go index a4c0578cc..449c8303f 100644 --- a/internal/command/meta_backend_migrate.go +++ b/internal/command/meta_backend_migrate.go @@ -694,8 +694,7 @@ func (m *Meta) promptNewWorkspaceName(destinationType string) (string, error) { message := fmt.Sprintf("[reset][bold][yellow]The %q backend configuration only allows "+ "named workspaces![reset]", destinationType) if destinationType == "cloud" { - message = fmt.Sprintf("[reset][bold][yellow]The Terraform Cloud configuration only allows " + - "named workspaces![reset]") + message = `[reset][bold][yellow]Terraform Cloud requires all workspaces to be given an explicit name.[reset]` } name, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{ Id: "new-state-name", @@ -896,7 +895,7 @@ If you answer "yes", Terraform will migrate all states. If you answer const inputBackendNewWorkspaceName = ` Please provide a new workspace name (e.g. dev, test) that will be used -to migrate the existing default workspace. +to migrate the existing default workspace. ` const inputBackendSelectWorkspace = `