Skip to content

Commit

Permalink
Add in logic for handling a field of 'data' to kv get (#4895)
Browse files Browse the repository at this point in the history
We do this for normal commands in PrintRawField but it needs some help
for KV v2.
  • Loading branch information
jefferai authored Jul 11, 2018
1 parent a1321d1 commit 229dee1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions command/kv_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 229dee1

Please sign in to comment.