Sync some ns stuff to api/command

This commit is contained in:
Jeff Mitchell
2018-08-22 14:37:40 -04:00
parent a60e39489c
commit dc9d3f3012
14 changed files with 237 additions and 233 deletions

View File

@@ -16,14 +16,14 @@ type NamespaceLookupCommand struct {
}
func (c *NamespaceLookupCommand) Synopsis() string {
return "Create a new namespace"
return "Look up an existing namespace"
}
func (c *NamespaceLookupCommand) Help() string {
helpText := `
Usage: vault namespace create [options] PATH
Create a child namespace. The namespace created will be relative to the
Create a child namespace. The namespace created will be relative to the
namespace provided in either VAULT_NAMESPACE environemnt variable or
-namespace CLI flag.
@@ -33,7 +33,7 @@ Usage: vault namespace create [options] PATH
Get information about the namespace of a particular child token (e.g. ns1/ns2/):
$ vault namespace create -namespace=ns1 ns2
$ vault namespace lookup -namespace=ns1 ns2
` + c.Flags().Help()
@@ -78,19 +78,15 @@ func (c *NamespaceLookupCommand) Run(args []string) int {
return 2
}
resp, err := client.Sys().GetNamespace(namespacePath)
secret, err := client.Logical().Read("sys/namespaces/" + namespacePath)
if err != nil {
c.UI.Error(fmt.Sprintf("Error looking up namespace: %s", err))
return 2
}
switch Format(c.UI) {
case "table":
data := map[string]interface{}{
"path": resp.Path,
}
return OutputData(c.UI, data)
default:
return OutputData(c.UI, resp)
if secret == nil {
c.UI.Error("Namespace not found")
return 2
}
return OutputSecret(c.UI, secret)
}