Skip to content

Commit 37b25f2

Browse files
committed
cli/command/plugins: runRemove: fix incorrect use of errors.Join
commit 71ebbb8 replaced 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]: 71ebbb8#r1810257735 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 4808d1b commit 37b25f2

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

cli/command/plugin/remove.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
3636
return cmd
3737
}
3838

39-
func runRemove(ctx context.Context, dockerCli command.Cli, opts *rmOptions) error {
40-
var errs error
39+
func runRemove(ctx context.Context, dockerCLI command.Cli, opts *rmOptions) error {
40+
apiClient := dockerCLI.Client()
41+
42+
var errs []error
4143
for _, name := range opts.plugins {
42-
if err := dockerCli.Client().PluginRemove(ctx, name, types.PluginRemoveOptions{Force: opts.force}); err != nil {
43-
errs = errors.Join(errs, err)
44+
if err := apiClient.PluginRemove(ctx, name, types.PluginRemoveOptions{Force: opts.force}); err != nil {
45+
errs = append(errs, err)
4446
continue
4547
}
46-
_, _ = fmt.Fprintln(dockerCli.Out(), name)
48+
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
4749
}
48-
return errs
50+
return errors.Join(errs...)
4951
}

0 commit comments

Comments
 (0)