diff --git a/command/meta.go b/command/meta.go index 27f7765f9..04c757497 100644 --- a/command/meta.go +++ b/command/meta.go @@ -476,7 +476,8 @@ func (m *Meta) confirm(opts *terraform.InputOpts) (bool, error) { if !m.Input() { return false, errors.New("input is disabled") } - for { + + for i := 0; i < 2; i++ { v, err := m.UIInput().Input(opts) if err != nil { return false, fmt.Errorf( @@ -490,6 +491,7 @@ func (m *Meta) confirm(opts *terraform.InputOpts) (bool, error) { return true, nil } } + return false, nil } // showDiagnostics displays error and warning messages in the UI. diff --git a/command/meta_backend_migrate.go b/command/meta_backend_migrate.go index 552d70887..21c33d66d 100644 --- a/command/meta_backend_migrate.go +++ b/command/meta_backend_migrate.go @@ -346,22 +346,7 @@ func (m *Meta) backendMigrateEmptyConfirm(one, two state.State, opts *backendMig opts.OneType, opts.TwoType), } - // Confirm with the user that the copy should occur - for { - v, err := m.UIInput().Input(inputOpts) - if err != nil { - return false, fmt.Errorf( - "Error asking for state copy action: %s", err) - } - - switch strings.ToLower(v) { - case "no": - return false, nil - - case "yes": - return true, nil - } - } + return m.confirm(inputOpts) } func (m *Meta) backendMigrateNonEmptyConfirm( @@ -410,21 +395,7 @@ func (m *Meta) backendMigrateNonEmptyConfirm( } // Confirm with the user that the copy should occur - for { - v, err := m.UIInput().Input(inputOpts) - if err != nil { - return false, fmt.Errorf( - "Error asking for state copy action: %s", err) - } - - switch strings.ToLower(v) { - case "no": - return false, nil - - case "yes": - return true, nil - } - } + return m.confirm(inputOpts) } type backendMigrateOpts struct {