Skip to content

Commit

Permalink
list, kv list and namespace list with format json returns json, not a…
Browse files Browse the repository at this point in the history
… string
  • Loading branch information
michelvocks committed May 30, 2019
1 parent d901cef commit 0975731
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
11 changes: 10 additions & 1 deletion command/kv_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ func (c *KVListCommand) Run(args []string) int {
c.UI.Error(fmt.Sprintf("Error listing %s: %s", path, err))
return 2
}

_, ok := extractListData(secret)
if Format(c.UI) != "table" {
if secret == nil || secret.Data == nil || !ok {
OutputData(c.UI, map[string]interface{}{})
return 2
}
}

if secret == nil || secret.Data == nil {
c.UI.Error(fmt.Sprintf("No value found at %s", path))
return 2
Expand All @@ -103,7 +112,7 @@ func (c *KVListCommand) Run(args []string) int {
return OutputSecret(c.UI, secret)
}

if _, ok := extractListData(secret); !ok {
if !ok {
c.UI.Error(fmt.Sprintf("No entries found at %s", path))
return 2
}
Expand Down
11 changes: 10 additions & 1 deletion command/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ func (c *ListCommand) Run(args []string) int {
c.UI.Error(fmt.Sprintf("Error listing %s: %s", path, err))
return 2
}

_, ok := extractListData(secret)
if Format(c.UI) != "table" {
if secret == nil || secret.Data == nil || !ok {
OutputData(c.UI, map[string]interface{}{})
return 2
}
}

if secret == nil {
c.UI.Error(fmt.Sprintf("No value found at %s", path))
return 2
Expand All @@ -97,7 +106,7 @@ func (c *ListCommand) Run(args []string) int {
return OutputSecret(c.UI, secret)
}

if _, ok := extractListData(secret); !ok {
if !ok {
c.UI.Error(fmt.Sprintf("No entries found at %s", path))
return 2
}
Expand Down
11 changes: 10 additions & 1 deletion command/namespace_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ func (c *NamespaceListCommand) Run(args []string) int {
c.UI.Error(fmt.Sprintf("Error listing namespaces: %s", err))
return 2
}

_, ok := extractListData(secret)
if Format(c.UI) != "table" {
if secret == nil || secret.Data != nil || !ok {
OutputData(c.UI, map[string]interface{}{})
return 2
}
}

if secret == nil {
c.UI.Error(fmt.Sprintf("No namespaces found"))
return 2
Expand All @@ -85,7 +94,7 @@ func (c *NamespaceListCommand) Run(args []string) int {
return OutputSecret(c.UI, secret)
}

if _, ok := extractListData(secret); !ok {
if !ok {
c.UI.Error(fmt.Sprintf("No entries found"))
return 2
}
Expand Down

0 comments on commit 0975731

Please sign in to comment.