mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Sync over
This commit is contained in:
@@ -2,7 +2,6 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
@@ -42,7 +41,7 @@ Usage: vault namespace create [options] PATH
|
||||
}
|
||||
|
||||
func (c *NamespaceCreateCommand) Flags() *FlagSets {
|
||||
return c.flagSet(FlagSetHTTP)
|
||||
return c.flagSet(FlagSetHTTP | FlagSetOutputField | FlagSetOutputFormat)
|
||||
}
|
||||
|
||||
func (c *NamespaceCreateCommand) AutocompleteArgs() complete.Predictor {
|
||||
@@ -79,21 +78,16 @@ func (c *NamespaceCreateCommand) Run(args []string) int {
|
||||
return 2
|
||||
}
|
||||
|
||||
_, err = client.Logical().Write("sys/namespaces/"+namespacePath, nil)
|
||||
secret, err := client.Logical().Write("sys/namespaces/"+namespacePath, nil)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating namespace: %s", err))
|
||||
return 2
|
||||
}
|
||||
|
||||
if c.flagNamespace != notSetNamespace {
|
||||
namespacePath = path.Join(c.flagNamespace, namespacePath)
|
||||
// Handle single field output
|
||||
if c.flagField != "" {
|
||||
return PrintRawField(c.UI, secret, c.flagField)
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(namespacePath, "/") {
|
||||
namespacePath = namespacePath + "/"
|
||||
}
|
||||
|
||||
// Output full path
|
||||
c.UI.Output(fmt.Sprintf("Success! Namespace created at: %s", namespacePath))
|
||||
return 0
|
||||
return OutputSecret(c.UI, secret)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
@@ -90,10 +89,6 @@ func (c *NamespaceDeleteCommand) Run(args []string) int {
|
||||
return OutputSecret(c.UI, secret)
|
||||
}
|
||||
|
||||
if c.flagNamespace != notSetNamespace {
|
||||
namespacePath = path.Join(c.flagNamespace, namespacePath)
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(namespacePath, "/") {
|
||||
namespacePath = namespacePath + "/"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user