Skip to content

Commit 40dd429

Browse files
authored
Merge pull request #29438 from hashicorp/alisdair/init-force-copy-multiple-workspaces
command: Suppress prompt for init -force-copy
2 parents dbee7e1 + 2762a94 commit 40dd429

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

internal/command/meta_backend_migrate.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,23 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
146146
func (m *Meta) backendMigrateState_S_S(opts *backendMigrateOpts) error {
147147
log.Print("[TRACE] backendMigrateState: migrating all named workspaces")
148148

149-
// Ask the user if they want to migrate their existing remote state
150-
migrate, err := m.confirm(&terraform.InputOpts{
151-
Id: "backend-migrate-multistate-to-multistate",
152-
Query: fmt.Sprintf(
153-
"Do you want to migrate all workspaces to %q?",
154-
opts.TwoType),
155-
Description: fmt.Sprintf(
156-
strings.TrimSpace(inputBackendMigrateMultiToMulti),
157-
opts.OneType, opts.TwoType),
158-
})
159-
if err != nil {
160-
return fmt.Errorf(
161-
"Error asking for state migration action: %s", err)
149+
migrate := opts.force
150+
if !migrate {
151+
var err error
152+
// Ask the user if they want to migrate their existing remote state
153+
migrate, err = m.confirm(&terraform.InputOpts{
154+
Id: "backend-migrate-multistate-to-multistate",
155+
Query: fmt.Sprintf(
156+
"Do you want to migrate all workspaces to %q?",
157+
opts.TwoType),
158+
Description: fmt.Sprintf(
159+
strings.TrimSpace(inputBackendMigrateMultiToMulti),
160+
opts.OneType, opts.TwoType),
161+
})
162+
if err != nil {
163+
return fmt.Errorf(
164+
"Error asking for state migration action: %s", err)
165+
}
162166
}
163167
if !migrate {
164168
return fmt.Errorf("Migration aborted by user.")

0 commit comments

Comments
 (0)