Make the `list` and `kv list` commands work with wrapping, e.g. for controlgroups (#12031)

This commit is contained in:
Nick Cabatoff 2021-07-09 18:08:58 +02:00 committed by GitHub
parent 349378454a
commit 518944c599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

3
changelog/12031.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
cli: Add support for response wrapping in `vault list` and `vault kv list` with output format other than `table`.
```

View File

@ -103,6 +103,11 @@ func (c *KVListCommand) Run(args []string) int {
return 2
}
// If the secret is wrapped, return the wrapped response.
if secret != nil && secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 {
return OutputSecret(c.UI, secret)
}
_, ok := extractListData(secret)
if Format(c.UI) != "table" {
if secret == nil || secret.Data == nil || !ok {
@ -116,11 +121,6 @@ func (c *KVListCommand) Run(args []string) int {
return 2
}
// If the secret is wrapped, return the wrapped response.
if secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 {
return OutputSecret(c.UI, secret)
}
if !ok {
c.UI.Error(fmt.Sprintf("No entries found at %s", path))
return 2

View File

@ -90,6 +90,11 @@ func (c *ListCommand) Run(args []string) int {
return 2
}
// If the secret is wrapped, return the wrapped response.
if secret != nil && secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 {
return OutputSecret(c.UI, secret)
}
_, ok := extractListData(secret)
if Format(c.UI) != "table" {
if secret == nil || secret.Data == nil || !ok {
@ -108,11 +113,6 @@ func (c *ListCommand) Run(args []string) int {
return OutputSecret(c.UI, secret)
}
// If the secret is wrapped, return the wrapped response.
if secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 {
return OutputSecret(c.UI, secret)
}
if !ok {
c.UI.Error(fmt.Sprintf("No entries found at %s", path))
return 2