mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +02:00
Add in logic for handling a field of 'data' to kv get (#4895)
We do this for normal commands in PrintRawField but it needs some help for KV v2.
This commit is contained in:
parent
a1321d1d9c
commit
229dee1be0
@ -130,6 +130,16 @@ func (c *KVGetCommand) Run(args []string) int {
|
||||
if v2 {
|
||||
// This is a v2, pass in the data field
|
||||
if data, ok := secret.Data["data"]; ok && data != nil {
|
||||
// If they requested a literal "data" see if they meant actual
|
||||
// value or the data block itself
|
||||
if c.flagField == "data" {
|
||||
if dataMap, ok := data.(map[string]interface{}); ok {
|
||||
if _, ok := dataMap["data"]; ok {
|
||||
return PrintRawField(c.UI, dataMap, c.flagField)
|
||||
}
|
||||
}
|
||||
return PrintRawField(c.UI, secret, c.flagField)
|
||||
}
|
||||
return PrintRawField(c.UI, data, c.flagField)
|
||||
} else {
|
||||
c.UI.Error(fmt.Sprintf("No data found at %s", path))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user