Skip to content

Commit cfc1c49

Browse files
command/login: Use Cli.Ask to request confirmation
This is more straightforward than using readline because it already works properly with panicwrap.
1 parent 0b346e5 commit cfc1c49

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

command/login.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/hashicorp/terraform/httpclient"
1818
"github.com/hashicorp/terraform/svchost"
1919
"github.com/hashicorp/terraform/svchost/disco"
20-
"github.com/hashicorp/terraform/terraform"
2120
"github.com/hashicorp/terraform/tfdiags"
2221

2322
uuid "github.com/hashicorp/go-uuid"
@@ -434,11 +433,7 @@ func (c *LoginCommand) interactiveContextConsent(hostname svchost.Hostname, gran
434433
}
435434
}
436435

437-
v, err := c.UIInput().Input(context.Background(), &terraform.InputOpts{
438-
Id: "confirm",
439-
Query: "Do you want to proceed with login and store the new credentials?",
440-
Description: "Enter 'y' or 'yes' to confirm.",
441-
})
436+
v, err := c.prompt("Do you want to proceed? (y/n)", false)
442437
if err != nil {
443438
// Should not happen because this command checks that input is enabled
444439
// before we get to this point.

main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ func init() {
106106
OutputPrefix: OutputPrefix,
107107
InfoPrefix: OutputPrefix,
108108
ErrorPrefix: ErrorPrefix,
109-
Ui: &cli.BasicUi{Writer: os.Stdout},
109+
Ui: &cli.BasicUi{
110+
Writer: os.Stdout,
111+
Reader: os.Stdin,
112+
},
110113
}
111114
}
112115

0 commit comments

Comments
 (0)