MCPcopy Create free account
hub / github.com/hashicorp/vault / Run

Method Run

command/secrets_enable.go:273–402  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

271}
272
273func (c *SecretsEnableCommand) Run(args []string) int {
274 f := c.Flags()
275
276 if err := f.Parse(args); err != nil {
277 c.UI.Error(err.Error())
278 return 1
279 }
280
281 args = f.Args()
282 switch {
283 case len(args) < 1:
284 c.UI.Error(fmt.Sprintf("Not enough arguments (expected 1, got %d)", len(args)))
285 return 1
286 case len(args) > 1:
287 c.UI.Error(fmt.Sprintf("Too many arguments (expected 1, got %d)", len(args)))
288 return 1
289 }
290
291 client, err := c.Client()
292 if err != nil {
293 c.UI.Error(err.Error())
294 return 2
295 }
296
297 // Get the engine type type (first arg)
298 engineType := strings.TrimSpace(args[0])
299 if engineType == "plugin" {
300 engineType = c.flagPluginName
301 }
302
303 // If no path is specified, we default the path to the backend type
304 // or use the plugin name if it's a plugin backend
305 mountPath := c.flagPath
306 if mountPath == "" {
307 if engineType == "plugin" {
308 mountPath = c.flagPluginName
309 } else {
310 mountPath = engineType
311 }
312 }
313
314 if c.flagVersion > 0 {
315 if c.flagOptions == nil {
316 c.flagOptions = make(map[string]string)
317 }
318 c.flagOptions["version"] = strconv.Itoa(c.flagVersion)
319 }
320
321 // Append a trailing slash to indicate it's a path in output
322 mountPath = ensureTrailingSlash(mountPath)
323
324 // Build mount input
325 mountInput := &api.MountInput{
326 Type: engineType,
327 Description: c.flagDescription,
328 Local: c.flagLocal,
329 SealWrap: c.flagSealWrap,
330 ExternalEntropyAccess: c.flagExternalEntropyAccess,

Callers

nothing calls this directly

Calls 13

FlagsMethod · 0.95
ArgsMethod · 0.80
IsSetMethod · 0.80
SysMethod · 0.80
ensureTrailingSlashFunction · 0.70
ParseMethod · 0.65
ErrorMethod · 0.65
ClientMethod · 0.65
StringMethod · 0.65
GetMethod · 0.65
OutputMethod · 0.65
VisitMethod · 0.45

Tested by

no test coverage detected