mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
cli: Improve error handling for plugin commands (#24250)
* Stop supporting vault plugin info and deregister without a type argument * Make a best-effort attempt to report whether a plugin was actually deregistered and give more descriptive errors * Fix error message for vault plugin reload
This commit is contained in:
@@ -77,23 +77,19 @@ func (c *PluginInfoCommand) Run(args []string) int {
|
||||
|
||||
var pluginNameRaw, pluginTypeRaw string
|
||||
args = f.Args()
|
||||
positionalArgsCount := len(args)
|
||||
switch {
|
||||
case len(args) < 1:
|
||||
c.UI.Error(fmt.Sprintf("Not enough arguments (expected 1 or 2, got %d)", len(args)))
|
||||
case positionalArgsCount < 2:
|
||||
c.UI.Error(fmt.Sprintf("Not enough arguments (expected 2, got %d)", positionalArgsCount))
|
||||
return 1
|
||||
case len(args) > 2:
|
||||
c.UI.Error(fmt.Sprintf("Too many arguments (expected 1 or 2, got %d)", len(args)))
|
||||
case positionalArgsCount > 2:
|
||||
c.UI.Error(fmt.Sprintf("Too many arguments (expected 2, got %d)", positionalArgsCount))
|
||||
return 1
|
||||
|
||||
// These cases should come after invalid cases have been checked
|
||||
case len(args) == 1:
|
||||
pluginTypeRaw = "unknown"
|
||||
pluginNameRaw = args[0]
|
||||
case len(args) == 2:
|
||||
pluginTypeRaw = args[0]
|
||||
pluginNameRaw = args[1]
|
||||
}
|
||||
|
||||
pluginTypeRaw = args[0]
|
||||
pluginNameRaw = args[1]
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
|
||||
Reference in New Issue
Block a user