mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-13 14:51:34 +01:00
Core: interactive CLI improvement VAULT_ADDR warning message (#17076)
This commit is contained in:
parent
b0e8471b87
commit
40e00d812f
4
changelog/17076.txt
Normal file
4
changelog/17076.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
core/cli: Warning related to VAULT_ADDR & -address not set with CLI requests.
|
||||||
|
```
|
||||||
|
|
||||||
@ -63,6 +63,7 @@ type BaseCommand struct {
|
|||||||
flagOutputCurlString bool
|
flagOutputCurlString bool
|
||||||
flagOutputPolicy bool
|
flagOutputPolicy bool
|
||||||
flagNonInteractive bool
|
flagNonInteractive bool
|
||||||
|
addrWarning string
|
||||||
|
|
||||||
flagMFA []string
|
flagMFA []string
|
||||||
|
|
||||||
@ -81,6 +82,14 @@ func (c *BaseCommand) Client() (*api.Client, error) {
|
|||||||
return c.client, nil
|
return c.client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.addrWarning != "" && c.UI != nil {
|
||||||
|
if os.Getenv("VAULT_ADDR") == "" {
|
||||||
|
if !c.flagNonInteractive && isatty.IsTerminal(os.Stdin.Fd()) {
|
||||||
|
c.UI.Warn(wrapAtLength(c.addrWarning))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config := api.DefaultConfig()
|
config := api.DefaultConfig()
|
||||||
|
|
||||||
if err := config.ReadEnvironment(); err != nil {
|
if err := config.ReadEnvironment(); err != nil {
|
||||||
@ -321,10 +330,12 @@ func (c *BaseCommand) flagSet(bit FlagSetBit) *FlagSets {
|
|||||||
Completion: complete.PredictAnything,
|
Completion: complete.PredictAnything,
|
||||||
Usage: "Address of the Vault server.",
|
Usage: "Address of the Vault server.",
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.flagAddress != "" {
|
if c.flagAddress != "" {
|
||||||
addrStringVar.Default = c.flagAddress
|
addrStringVar.Default = c.flagAddress
|
||||||
} else {
|
} else {
|
||||||
addrStringVar.Default = "https://127.0.0.1:8200"
|
addrStringVar.Default = "https://127.0.0.1:8200"
|
||||||
|
c.addrWarning = fmt.Sprintf("WARNING! VAULT_ADDR and -address unset. Defaulting to %s.", addrStringVar.Default)
|
||||||
}
|
}
|
||||||
f.StringVar(addrStringVar)
|
f.StringVar(addrStringVar)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user