(args []string)
| 71 | } |
| 72 | |
| 73 | func (c *NamespaceCreateCommand) Run(args []string) int { |
| 74 | f := c.Flags() |
| 75 | |
| 76 | if err := f.Parse(args); err != nil { |
| 77 | c.UI.Error(err.Error()) |
| 78 | return 1 |
| 79 | } |
| 80 | |
| 81 | args = f.Args() |
| 82 | switch { |
| 83 | case len(args) < 1: |
| 84 | c.UI.Error(fmt.Sprintf("Not enough arguments (expected 1, got %d)", len(args))) |
| 85 | return 1 |
| 86 | case len(args) > 1: |
| 87 | c.UI.Error(fmt.Sprintf("Too many arguments (expected 1, got %d)", len(args))) |
| 88 | return 1 |
| 89 | } |
| 90 | |
| 91 | namespacePath := strings.TrimSpace(args[0]) |
| 92 | |
| 93 | client, err := c.Client() |
| 94 | if err != nil { |
| 95 | c.UI.Error(err.Error()) |
| 96 | return 2 |
| 97 | } |
| 98 | |
| 99 | data := map[string]interface{}{ |
| 100 | "custom_metadata": c.flagCustomMetadata, |
| 101 | } |
| 102 | |
| 103 | secret, err := client.Logical().Write("sys/namespaces/"+namespacePath, data) |
| 104 | if err != nil { |
| 105 | c.UI.Error(fmt.Sprintf("Error creating namespace: %s", err)) |
| 106 | return 2 |
| 107 | } |
| 108 | |
| 109 | // Handle single field output |
| 110 | if c.flagField != "" { |
| 111 | return PrintRawField(c.UI, secret, c.flagField) |
| 112 | } |
| 113 | |
| 114 | return OutputSecret(c.UI, secret) |
| 115 | } |
nothing calls this directly
no test coverage detected