refactor(api module): enforce typed definitions (#2238)
This commit is contained in:
1 parent
d6c1402223
commit
c2bfcc0664
79 files changed
+906
-551
No files matched your search
@@ -198,19 +198,28 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
return base.CommandUserError
|
||||
}
|
||||
|
||||
var result api.GenericResult
|
||||
var resp *api.Response
|
||||
var item *authmethods.AuthMethod
|
||||
|
||||
var createResult *authmethods.AuthMethodCreateResult
|
||||
|
||||
var updateResult *authmethods.AuthMethodUpdateResult
|
||||
|
||||
switch c.Func {
|
||||
|
||||
case "create":
|
||||
result, err = authmethodsClient.Create(c.Context, "password", c.FlagScopeId, opts...)
|
||||
createResult, err = authmethodsClient.Create(c.Context, "password", c.FlagScopeId, opts...)
|
||||
resp = createResult.GetResponse()
|
||||
item = createResult.GetItem()
|
||||
|
||||
case "update":
|
||||
result, err = authmethodsClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
updateResult, err = authmethodsClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
resp = updateResult.GetResponse()
|
||||
item = updateResult.GetItem()
|
||||
|
||||
}
|
||||
|
||||
result, err = executeExtraPasswordActions(c, result, err, authmethodsClient, version, opts)
|
||||
resp, item, err = executeExtraPasswordActions(c, resp, item, err, authmethodsClient, version, opts)
|
||||
|
||||
if err != nil {
|
||||
if apiErr := api.AsServerError(err); apiErr != nil {
|
||||
@@ -238,10 +247,10 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(printItemTable(result))
|
||||
c.UI.Output(printItemTable(item, resp))
|
||||
|
||||
case "json":
|
||||
if ok := c.PrintJsonItem(result); !ok {
|
||||
if ok := c.PrintJsonItem(resp); !ok {
|
||||
return base.CommandCliError
|
||||
}
|
||||
}
|
||||
@@ -254,8 +263,8 @@ var (
|
||||
extraPasswordSynopsisFunc = func(*PasswordCommand) string { return "" }
|
||||
extraPasswordFlagsFunc = func(*PasswordCommand, *base.FlagSets, *base.FlagSet) {}
|
||||
extraPasswordFlagsHandlingFunc = func(*PasswordCommand, *base.FlagSets, *[]authmethods.Option) bool { return true }
|
||||
executeExtraPasswordActions = func(_ *PasswordCommand, inResult api.GenericResult, inErr error, _ *authmethods.Client, _ uint32, _ []authmethods.Option) (api.GenericResult, error) {
|
||||
return inResult, inErr
|
||||
executeExtraPasswordActions = func(_ *PasswordCommand, inResp *api.Response, inItem *authmethods.AuthMethod, inErr error, _ *authmethods.Client, _ uint32, _ []authmethods.Option) (*api.Response, *authmethods.AuthMethod, error) {
|
||||
return inResp, inItem, inErr
|
||||
}
|
||||
printCustomPasswordActionOutput = func(*PasswordCommand) (bool, error) { return false, nil }
|
||||
)
|
||||
Reference in new issue
Block a user