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...) }