1 parent
b967ff7f05
commit
72aa110f72
50 files changed
+489
-540
No files matched your search
@@ -2,6 +2,7 @@
|
||||
package authmethodscmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
@@ -114,12 +115,12 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
c.PrintCliError(err)
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsPasswordMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
c.PrintCliError(errors.New("ID is required but not passed in via -id"))
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
switch c.Func {
|
||||
case "create":
|
||||
if c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id or BOUNDARY_SCOPE_ID")
|
||||
c.PrintCliError(errors.New("Scope ID must be passed in via -scope-id or BOUNDARY_SCOPE_ID"))
|
||||
return 1
|
||||
}
|
||||
}
|
||||
@@ -137,7 +138,7 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
c.PrintCliError(fmt.Errorf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
authmethodsClient := authmethods.NewClient(client)
|
||||
@@ -195,16 +196,16 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
|
||||
if err != nil {
|
||||
if apiErr := api.AsServerError(err); apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, c.plural, base.PrintApiError(apiErr)))
|
||||
c.PrintApiError(apiErr, fmt.Sprintf("Error from controller when performing %s on %s", c.Func, c.plural))
|
||||
return 1
|
||||
}
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, c.plural, err.Error()))
|
||||
c.PrintCliError(fmt.Errorf("Error trying to %s %s: %s", c.Func, c.plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
output, err := printCustomPasswordActionOutput(c)
|
||||
if err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
c.PrintCliError(err)
|
||||
return 1
|
||||
}
|
||||
if output {
|
||||
@@ -220,12 +221,7 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
c.UI.Output(printItemTable(item))
|
||||
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(item)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
return c.PrintJsonItem(result, item)
|
||||
}
|
||||
|
||||
return 0
|
||||
|
||||
Reference in new issue
Block a user