Skip to content

Commit

Permalink
Merge branch 'master' into approle-local-secretid
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnayak authored Apr 24, 2018
2 parents cce5861 + 7e1ef27 commit 7837f11
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions command/kv_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func (c *KVGetCommand) Run(args []string) int {
secret, err := kvReadRequest(client, path, versionParam)
if err != nil {
c.UI.Error(fmt.Sprintf("Error reading %s: %s", path, err))
if secret != nil {
OutputSecret(c.UI, secret)
}
return 2
}
if secret == nil {
Expand All @@ -142,6 +145,11 @@ func (c *KVGetCommand) Run(args []string) int {
return OutputSecret(c.UI, secret)
}

if len(secret.Warnings) > 0 {
tf := TableFormatter{}
tf.printWarnings(c.UI, secret)
}

if metadata, ok := secret.Data["metadata"]; ok && metadata != nil {
c.UI.Info(getHeaderForMap("Metadata", metadata.(map[string]interface{})))
OutputData(c.UI, metadata)
Expand Down
6 changes: 6 additions & 0 deletions command/kv_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func kvPreflightVersionRequest(client *api.Client, path string) (string, int, er
defer resp.Body.Close()
}
if err != nil {
// If we get a 404 we are using an older version of vault, default to
// version 1
if resp != nil && resp.StatusCode == 404 {
return "", 1, nil
}

return "", 0, err
}

Expand Down
3 changes: 3 additions & 0 deletions command/kv_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func (c *KVPutCommand) Run(args []string) int {
secret, err := client.Logical().Write(path, data)
if err != nil {
c.UI.Error(fmt.Sprintf("Error writing data to %s: %s", path, err))
if secret != nil {
OutputSecret(c.UI, secret)
}
return 2
}
if secret == nil {
Expand Down

0 comments on commit 7837f11

Please sign in to comment.