mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Sync some ns stuff to api/command
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user