mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Add the ability to print curl commands from CLI (#6113)
This commit is contained in:
@@ -50,8 +50,9 @@ type BaseCommand struct {
|
||||
flagTLSSkipVerify bool
|
||||
flagWrapTTL time.Duration
|
||||
|
||||
flagFormat string
|
||||
flagField string
|
||||
flagFormat string
|
||||
flagField string
|
||||
flagOutputCurlString bool
|
||||
|
||||
flagMFA []string
|
||||
|
||||
@@ -78,6 +79,10 @@ func (c *BaseCommand) Client() (*api.Client, error) {
|
||||
config.Address = c.flagAddress
|
||||
}
|
||||
|
||||
if c.flagOutputCurlString {
|
||||
config.OutputCurlString = c.flagOutputCurlString
|
||||
}
|
||||
|
||||
// If we need custom TLS configuration, then set it
|
||||
if c.flagCACert != "" || c.flagCAPath != "" || c.flagClientCert != "" ||
|
||||
c.flagClientKey != "" || c.flagTLSServerName != "" || c.flagTLSSkipVerify {
|
||||
@@ -325,6 +330,15 @@ func (c *BaseCommand) flagSet(bit FlagSetBit) *FlagSets {
|
||||
Completion: complete.PredictAnything,
|
||||
Usage: "Supply MFA credentials as part of X-Vault-MFA header.",
|
||||
})
|
||||
|
||||
f.BoolVar(&BoolVar{
|
||||
Name: "output-curl-string",
|
||||
Target: &c.flagOutputCurlString,
|
||||
Default: false,
|
||||
Usage: "Instead of executing the request, print an equivalent cURL " +
|
||||
"command string and exit.",
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if bit&(FlagSetOutputField|FlagSetOutputFormat) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user