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

Method Run

command/secrets_list.go:78–115  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

76}
77
78func (c *SecretsListCommand) Run(args []string) int {
79 f := c.Flags()
80
81 if err := f.Parse(args); err != nil {
82 c.UI.Error(err.Error())
83 return 1
84 }
85
86 args = f.Args()
87 if len(args) > 0 {
88 c.UI.Error(fmt.Sprintf("Too many arguments (expected 0, got %d)", len(args)))
89 return 1
90 }
91
92 client, err := c.Client()
93 if err != nil {
94 c.UI.Error(err.Error())
95 return 2
96 }
97
98 mounts, err := client.Sys().ListMounts()
99 if err != nil {
100 c.UI.Error(fmt.Sprintf("Error listing secrets engines: %s", err))
101 return 2
102 }
103
104 switch Format(c.UI) {
105 case "table":
106 if c.flagDetailed {
107 c.UI.Output(tableOutput(c.detailedMounts(mounts), nil))
108 return 0
109 }
110 c.UI.Output(tableOutput(c.simpleMounts(mounts), nil))
111 return 0
112 default:
113 return OutputData(c.UI, mounts)
114 }
115}
116
117func (c *SecretsListCommand) simpleMounts(mounts map[string]*api.MountOutput) []string {
118 paths := make([]string, 0, len(mounts))

Callers

nothing calls this directly

Calls 13

FlagsMethod · 0.95
detailedMountsMethod · 0.95
simpleMountsMethod · 0.95
FormatFunction · 0.85
tableOutputFunction · 0.85
OutputDataFunction · 0.85
ArgsMethod · 0.80
SysMethod · 0.80
ParseMethod · 0.65
ErrorMethod · 0.65
ClientMethod · 0.65
ListMountsMethod · 0.65

Tested by

no test coverage detected