From 791e06b4351f58e130bd4821a90bb83238b96b09 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 3 Feb 2025 19:16:28 +0100 Subject: [PATCH] cli/command/config: RunConfigRemove: use errors.Join Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn --- cli/command/config/remove.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/cli/command/config/remove.go b/cli/command/config/remove.go index cd5403db05..01cbe331c1 100644 --- a/cli/command/config/remove.go +++ b/cli/command/config/remove.go @@ -2,12 +2,11 @@ package config import ( "context" + "errors" "fmt" - "strings" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -35,23 +34,17 @@ func newConfigRemoveCommand(dockerCli command.Cli) *cobra.Command { } // RunConfigRemove removes the given Swarm configs. -func RunConfigRemove(ctx context.Context, dockerCli command.Cli, opts RemoveOptions) error { - client := dockerCli.Client() - - var errs []string +func RunConfigRemove(ctx context.Context, dockerCLI command.Cli, opts RemoveOptions) error { + apiClient := dockerCLI.Client() + var errs []error for _, name := range opts.Names { - if err := client.ConfigRemove(ctx, name); err != nil { - errs = append(errs, err.Error()) + if err := apiClient.ConfigRemove(ctx, name); err != nil { + errs = append(errs, err) continue } - - fmt.Fprintln(dockerCli.Out(), name) + _, _ = fmt.Fprintln(dockerCLI.Out(), name) } - if len(errs) > 0 { - return errors.Errorf("%s", strings.Join(errs, "\n")) - } - - return nil + return errors.Join(errs...) }