command/login: Use Cli.Ask to request confirmation

This is more straightforward than using readline because it already works
properly with panicwrap.
This commit is contained in:
Martin Atkins 2019-08-09 17:58:03 -07:00
parent 0b346e589a
commit cfc1c4900d
2 changed files with 5 additions and 7 deletions

View File

@ -17,7 +17,6 @@ import (
"github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/httpclient"
"github.com/hashicorp/terraform/svchost" "github.com/hashicorp/terraform/svchost"
"github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/svchost/disco"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform/tfdiags" "github.com/hashicorp/terraform/tfdiags"
uuid "github.com/hashicorp/go-uuid" uuid "github.com/hashicorp/go-uuid"
@ -434,11 +433,7 @@ func (c *LoginCommand) interactiveContextConsent(hostname svchost.Hostname, gran
} }
} }
v, err := c.UIInput().Input(context.Background(), &terraform.InputOpts{ v, err := c.prompt("Do you want to proceed? (y/n)", false)
Id: "confirm",
Query: "Do you want to proceed with login and store the new credentials?",
Description: "Enter 'y' or 'yes' to confirm.",
})
if err != nil { if err != nil {
// Should not happen because this command checks that input is enabled // Should not happen because this command checks that input is enabled
// before we get to this point. // before we get to this point.

View File

@ -106,7 +106,10 @@ func init() {
OutputPrefix: OutputPrefix, OutputPrefix: OutputPrefix,
InfoPrefix: OutputPrefix, InfoPrefix: OutputPrefix,
ErrorPrefix: ErrorPrefix, ErrorPrefix: ErrorPrefix,
Ui: &cli.BasicUi{Writer: os.Stdout}, Ui: &cli.BasicUi{
Writer: os.Stdout,
Reader: os.Stdin,
},
} }
} }