Skip to content

Commit 71ebbb8

Browse files
committed
cli/command/plugins: use errors.Join instead of custom cli.Errors
This command was using a custom "multi-error" implementation, but it had some limitations, and the formatting wasn't great. This patch replaces it with Go's errors.Join. Before: docker plugin remove one two three Error response from daemon: plugin "one" not found, Error response from daemon: plugin "two" not found, Error response from daemon: plugin "three" not found After: docker plugin remove one two three Error response from daemon: plugin "one" not found Error response from daemon: plugin "two" not found Error response from daemon: plugin "three" not found Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 8a7c5ae commit 71ebbb8

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

cli/command/plugin/remove.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
"github.com/docker/cli/cli"
@@ -36,17 +37,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
3637
}
3738

3839
func runRemove(ctx context.Context, dockerCli command.Cli, opts *rmOptions) error {
39-
var errs cli.Errors
40+
var errs error
4041
for _, name := range opts.plugins {
4142
if err := dockerCli.Client().PluginRemove(ctx, name, types.PluginRemoveOptions{Force: opts.force}); err != nil {
42-
errs = append(errs, err)
43+
errs = errors.Join(errs, err)
4344
continue
4445
}
45-
fmt.Fprintln(dockerCli.Out(), name)
46+
_, _ = fmt.Fprintln(dockerCli.Out(), name)
4647
}
47-
// Do not simplify to `return errs` because even if errs == nil, it is not a nil-error interface value.
48-
if errs != nil {
49-
return errs
50-
}
51-
return nil
48+
return errs
5249
}

0 commit comments

Comments
 (0)