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.
This commit is contained in:
Chris Arcand 2021-10-28 10:37:06 -05:00
parent 6d9c919f55
commit 14260a5b4c
5 changed files with 8 additions and 9 deletions

View File

@ -307,7 +307,7 @@ func Test_migrate_multi_to_tfc_cloud_tags_strategy(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state"}, 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"}, userInput: []string{"dev", "1", "app-*", "1"},
postInputOutput: []string{ postInputOutput: []string{
`Would you like to rename your workspaces?`, `Would you like to rename your workspaces?`,

View File

@ -379,7 +379,7 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, 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"}, userInput: []string{"cloud-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`, `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{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, 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"}, userInput: []string{"cloud-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`, `Do you want to copy existing state to Terraform Cloud?`,

View File

@ -103,7 +103,7 @@ func Test_migrate_single_to_tfc(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state"}, 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"}, userInput: []string{"new-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`, `Do you want to copy existing state to Terraform Cloud?`,

View File

@ -134,7 +134,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, 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"}, userInput: []string{"new-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`, `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{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state"}, 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, expectError: true,
userInput: []string{"new-workspace", "yes"}, userInput: []string{"new-workspace", "yes"},
}, },

View File

@ -694,8 +694,7 @@ func (m *Meta) promptNewWorkspaceName(destinationType string) (string, error) {
message := fmt.Sprintf("[reset][bold][yellow]The %q backend configuration only allows "+ message := fmt.Sprintf("[reset][bold][yellow]The %q backend configuration only allows "+
"named workspaces![reset]", destinationType) "named workspaces![reset]", destinationType)
if destinationType == "cloud" { if destinationType == "cloud" {
message = fmt.Sprintf("[reset][bold][yellow]The Terraform Cloud configuration only allows " + message = `[reset][bold][yellow]Terraform Cloud requires all workspaces to be given an explicit name.[reset]`
"named workspaces![reset]")
} }
name, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{ name, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{
Id: "new-state-name", Id: "new-state-name",
@ -896,7 +895,7 @@ If you answer "yes", Terraform will migrate all states. If you answer
const inputBackendNewWorkspaceName = ` const inputBackendNewWorkspaceName = `
Please provide a new workspace name (e.g. dev, test) that will be used 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 = ` const inputBackendSelectWorkspace = `