Skip to content

Commit

Permalink
Merge pull request #29439 from hashicorp/backport/alisdair/init-force…
Browse files Browse the repository at this point in the history
…-copy-multiple-workspaces/partially-pumped-chow

Backport of command: Suppress prompt for init -force-copy into v1.0
  • Loading branch information
alisdair authored Aug 20, 2021
2 parents cb754ec + c91c22b commit 4f76f5d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions internal/command/meta_backend_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,23 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
func (m *Meta) backendMigrateState_S_S(opts *backendMigrateOpts) error {
log.Print("[TRACE] backendMigrateState: migrating all named workspaces")

// Ask the user if they want to migrate their existing remote state
migrate, err := m.confirm(&terraform.InputOpts{
Id: "backend-migrate-multistate-to-multistate",
Query: fmt.Sprintf(
"Do you want to migrate all workspaces to %q?",
opts.TwoType),
Description: fmt.Sprintf(
strings.TrimSpace(inputBackendMigrateMultiToMulti),
opts.OneType, opts.TwoType),
})
if err != nil {
return fmt.Errorf(
"Error asking for state migration action: %s", err)
migrate := opts.force
if !migrate {
var err error
// Ask the user if they want to migrate their existing remote state
migrate, err = m.confirm(&terraform.InputOpts{
Id: "backend-migrate-multistate-to-multistate",
Query: fmt.Sprintf(
"Do you want to migrate all workspaces to %q?",
opts.TwoType),
Description: fmt.Sprintf(
strings.TrimSpace(inputBackendMigrateMultiToMulti),
opts.OneType, opts.TwoType),
})
if err != nil {
return fmt.Errorf(
"Error asking for state migration action: %s", err)
}
}
if !migrate {
return fmt.Errorf("Migration aborted by user.")
Expand Down

0 comments on commit 4f76f5d

Please sign in to comment.