(args []string)
| 144 | } |
| 145 | |
| 146 | func (c *KVPatchCommand) Run(args []string) int { |
| 147 | f := c.Flags() |
| 148 | |
| 149 | if err := f.Parse(args); err != nil { |
| 150 | c.UI.Error(err.Error()) |
| 151 | return 1 |
| 152 | } |
| 153 | |
| 154 | args = f.Args() |
| 155 | // Pull our fake stdin if needed |
| 156 | stdin := (io.Reader)(os.Stdin) |
| 157 | if c.testStdin != nil { |
| 158 | stdin = c.testStdin |
| 159 | } |
| 160 | |
| 161 | switch { |
| 162 | case len(args) < 1: |
| 163 | c.UI.Error(fmt.Sprintf("Not enough arguments (expected >1, got %d)", len(args))) |
| 164 | return 1 |
| 165 | case len(c.flagRemoveData) == 0 && len(args) == 1: |
| 166 | c.UI.Error("Must supply data") |
| 167 | return 1 |
| 168 | } |
| 169 | |
| 170 | var err error |
| 171 | |
| 172 | client, err := c.Client() |
| 173 | if err != nil { |
| 174 | c.UI.Error(err.Error()) |
| 175 | return 2 |
| 176 | } |
| 177 | |
| 178 | newData, err := parseArgsData(stdin, args[1:]) |
| 179 | if err != nil { |
| 180 | c.UI.Error(fmt.Sprintf("Failed to parse K=V data: %s", err)) |
| 181 | return 1 |
| 182 | } |
| 183 | |
| 184 | // If true, we're working with "-mount=secret foo" syntax. |
| 185 | // If false, we're using "secret/foo" syntax. |
| 186 | mountFlagSyntax := c.flagMount != "" |
| 187 | |
| 188 | var ( |
| 189 | mountPath string |
| 190 | partialPath string |
| 191 | v2 bool |
| 192 | ) |
| 193 | |
| 194 | // Parse the paths and grab the KV version |
| 195 | if mountFlagSyntax { |
| 196 | // In this case, this arg is the secret path (e.g. "foo"). |
| 197 | partialPath = sanitizePath(args[0]) |
| 198 | mountPath, v2, err = isKVv2(sanitizePath(c.flagMount), client) |
| 199 | if err != nil { |
| 200 | c.UI.Error(err.Error()) |
| 201 | return 2 |
| 202 | } |
| 203 |
nothing calls this directly
no test coverage detected