Sync over

This commit is contained in:
Jeff Mitchell
2018-08-27 12:02:57 -04:00
parent fc66bb3d71
commit f1f6fb002d
2 changed files with 6 additions and 17 deletions

View File

@@ -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)
}