diff --git a/command/kv_list.go b/command/kv_list.go index faedd6f3f429..0066c1f13215 100644 --- a/command/kv_list.go +++ b/command/kv_list.go @@ -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 @@ -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 } diff --git a/command/list.go b/command/list.go index 56762151ac24..e29b842a9cf1 100644 --- a/command/list.go +++ b/command/list.go @@ -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 @@ -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 } diff --git a/command/namespace_list.go b/command/namespace_list.go index 893e1a76e4cd..f06579b0d898 100644 --- a/command/namespace_list.go +++ b/command/namespace_list.go @@ -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 @@ -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 }