mirror of
https://github.com/hashicorp/vault.git
synced 2026-06-11 01:42:06 -04:00
Add -no-print to 'vault login' (#4454)
Trivially manually tested Closes #2758
This commit is contained in:
parent
669ed87311
commit
9345aade8a
1 changed files with 19 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ type LoginCommand struct {
|
|||
flagMethod string
|
||||
flagPath string
|
||||
flagNoStore bool
|
||||
flagNoPrint bool
|
||||
flagTokenOnly bool
|
||||
|
||||
// Deprecations
|
||||
|
|
@ -114,6 +115,14 @@ func (c *LoginCommand) Flags() *FlagSets {
|
|||
"The token will only be displayed in the command output.",
|
||||
})
|
||||
|
||||
f.BoolVar(&BoolVar{
|
||||
Name: "no-print",
|
||||
Target: &c.flagNoPrint,
|
||||
Default: false,
|
||||
Usage: "Do not display the token. The token will be still be stored to the " +
|
||||
"configured token helper.",
|
||||
})
|
||||
|
||||
f.BoolVar(&BoolVar{
|
||||
Name: "token-only",
|
||||
Target: &c.flagTokenOnly,
|
||||
|
|
@ -192,6 +201,12 @@ func (c *LoginCommand) Run(args []string) int {
|
|||
c.flagField = "token"
|
||||
}
|
||||
|
||||
if c.flagNoStore && c.flagNoPrint {
|
||||
c.UI.Error(wrapAtLength(
|
||||
"-no-store and -no-print cannot be used together"))
|
||||
return 1
|
||||
}
|
||||
|
||||
// Get the auth method
|
||||
authMethod := sanitizePath(c.flagMethod)
|
||||
if authMethod == "" {
|
||||
|
|
@ -329,6 +344,10 @@ func (c *LoginCommand) Run(args []string) int {
|
|||
"Vault.") + "\n")
|
||||
}
|
||||
|
||||
if c.flagNoPrint {
|
||||
return 0
|
||||
}
|
||||
|
||||
// If the user requested a particular field, print that out now since we
|
||||
// are likely piping to another process.
|
||||
if c.flagField != "" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue