cli/command/plugins: runRemove: fix incorrect use of errors.Join
commit71ebbb81aereplaced the use of the custom "cli.Errors" type for stdlib's errors.Join, however it made a mistake by calling errors.Join for each error occurred, which "nests" each error instead of putting each error at the same level. Thanks to Paweł Gronowski for spotting this on the [pull request][1] [1]:71ebbb81ae (r1810257735)Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -36,14 +36,16 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runRemove(ctx context.Context, dockerCli command.Cli, opts *rmOptions) error {
|
||||
var errs error
|
||||
func runRemove(ctx context.Context, dockerCLI command.Cli, opts *rmOptions) error {
|
||||
apiClient := dockerCLI.Client()
|
||||
|
||||
var errs []error
|
||||
for _, name := range opts.plugins {
|
||||
if err := dockerCli.Client().PluginRemove(ctx, name, types.PluginRemoveOptions{Force: opts.force}); err != nil {
|
||||
errs = errors.Join(errs, err)
|
||||
if err := apiClient.PluginRemove(ctx, name, types.PluginRemoveOptions{Force: opts.force}); err != nil {
|
||||
errs = append(errs, err)
|
||||
continue
|
||||
}
|
||||
_, _ = fmt.Fprintln(dockerCli.Out(), name)
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
|
||||
}
|
||||
return errs
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user