From fa17fdf9d73e6b1a7259b9ae52453fea54a7fcc6 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 5 Aug 2022 19:27:14 -0400 Subject: [PATCH] Update wording and fix a missing prompt (#2329) --- internal/cmd/base/base.go | 12 +++++------- internal/cmd/commands/accountscmd/funcs.go | 8 ++++---- internal/cmd/commands/accountscmd/password_funcs.go | 2 +- internal/cmd/commands/authenticate/password.go | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/internal/cmd/base/base.go b/internal/cmd/base/base.go index 318b3257ca..98f5a8c7cc 100644 --- a/internal/cmd/base/base.go +++ b/internal/cmd/base/base.go @@ -231,6 +231,9 @@ func (c *Command) Client(opt ...Option) (*api.Client, error) { } switch { + case opts.withNoTokenValue: + c.client.SetToken("") + case c.FlagRecoveryConfig != "": wrapper, cleanupFunc, err := wrapper.GetWrapperFromPath( c.Context, @@ -286,9 +289,9 @@ func (c *Command) Client(opt ...Option) (*api.Client, error) { } c.client.SetToken(token) - case c.FlagToken == "" && os.Getenv(envToken) != "": + case os.Getenv(envToken) != "": // Backwards compat: allow reading from existing BOUNDARY_TOKEN env var - c.UI.Warn(`Direct usage of BOUNDARY_TOKEN env var is deprecated; please use "-token env://" format, e.g. "-token env://BOUNDARY_TOKEN" to specify an env var to use.`) + c.UI.Warn(`Direct usage of BOUNDARY_TOKEN env var is deprecated; please use "-token env://" format, e.g. "-token env://BOUNDARY_TOKEN" to specify an env var to use.`) c.client.SetToken(os.Getenv(envToken)) case c.client.Token() == "" && strings.ToLower(c.FlagKeyringType) != "none": @@ -303,10 +306,6 @@ func (c *Command) Client(opt ...Option) (*api.Client, error) { } } - if opts.withNoTokenValue { - c.client.SetToken("") - } - return c.client, nil } @@ -414,7 +413,6 @@ func (c *Command) FlagSet(bit FlagSetBit) *FlagSets { f.StringVar(&StringVar{ Name: "token", Target: &c.FlagToken, - EnvVar: envToken, Usage: `A URL pointing to a file on disk (file://) from which a token will be read or an env var (env://) from which the token will be read. Overrides the "token-name" parameter.`, }) diff --git a/internal/cmd/commands/accountscmd/funcs.go b/internal/cmd/commands/accountscmd/funcs.go index e74a323368..d2bada13d1 100644 --- a/internal/cmd/commands/accountscmd/funcs.go +++ b/internal/cmd/commands/accountscmd/funcs.go @@ -121,7 +121,7 @@ func extraFlagsHandlingFuncImpl(c *Command, _ *base.FlagSets, opts *[]accounts.O if strutil.StrListContains(flagsMap[c.Func], "password") { switch c.flagPassword { case "": - fmt.Print("Password is not set as flag, please enter it now (will be hidden): ") + fmt.Print("Please enter the password (it will be hidden): ") value, err := password.Read(os.Stdin) fmt.Print("\n") if err != nil { @@ -159,14 +159,13 @@ func extraFlagsHandlingFuncImpl(c *Command, _ *base.FlagSets, opts *[]accounts.O if strutil.StrListContains(flagsMap[c.Func], "current-password") { switch c.flagCurrentPassword { case "": - fmt.Print("Current password is not set as flag, please enter it now (will be hidden): ") + fmt.Print("Please enter the current password (it will be hidden): ") value, err := password.Read(os.Stdin) fmt.Print("\n") if err != nil { c.UI.Error(fmt.Sprintf("An error occurred attempting to read the password. The raw error message is shown below but usually this is because you attempted to pipe a value into the command or you are executing outside of a terminal (TTY). The raw error was:\n\n%s", err.Error())) return false } - fmt.Print("Please enter it one more time for confirmation: ") c.flagCurrentPassword = strings.TrimSpace(value) default: @@ -187,13 +186,14 @@ func extraFlagsHandlingFuncImpl(c *Command, _ *base.FlagSets, opts *[]accounts.O if strutil.StrListContains(flagsMap[c.Func], "new-password") { switch c.flagNewPassword { case "": - fmt.Print("New password is not set as flag, please enter it now (will be hidden): ") + fmt.Print("Please enter the new password (it will be hidden): ") value, err := password.Read(os.Stdin) fmt.Print("\n") if err != nil { c.UI.Error(fmt.Sprintf("An error occurred attempting to read the password. The raw error message is shown below but usually this is because you attempted to pipe a value into the command or you are executing outside of a terminal (TTY). The raw error was:\n\n%s", err.Error())) return false } + fmt.Print("Please enter it one more time for confirmation: ") confirmation, err := password.Read(os.Stdin) fmt.Print("\n") if err != nil { diff --git a/internal/cmd/commands/accountscmd/password_funcs.go b/internal/cmd/commands/accountscmd/password_funcs.go index c50319fbb7..c6dedf550f 100644 --- a/internal/cmd/commands/accountscmd/password_funcs.go +++ b/internal/cmd/commands/accountscmd/password_funcs.go @@ -97,7 +97,7 @@ func extraPasswordFlagsHandlingFuncImpl(c *PasswordCommand, _ *base.FlagSets, op if strutil.StrListContains(flagsPasswordMap[c.Func], "password") { switch c.flagPassword { case "": - fmt.Print("Password is not set as flag, please enter it now (will be hidden): ") + fmt.Print("Please enter the password (it will be hidden): ") value, err := password.Read(os.Stdin) fmt.Print("\n") if err != nil { diff --git a/internal/cmd/commands/authenticate/password.go b/internal/cmd/commands/authenticate/password.go index eb0abf03c7..b0dc40634a 100644 --- a/internal/cmd/commands/authenticate/password.go +++ b/internal/cmd/commands/authenticate/password.go @@ -104,7 +104,7 @@ func (c *PasswordCommand) Run(args []string) int { switch c.flagPassword { case "": - fmt.Print("Password is not set as flag or in env, please enter it now (will be hidden): ") + fmt.Print("Please enter the password (it will be hidden): ") value, err := password.Read(os.Stdin) fmt.Print("\n") if err != nil {