From f8729c6da2210057657e31123c29fd92235f5ad1 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 3 Feb 2025 19:30:25 +0100 Subject: [PATCH] cli/command/manifest: use errors.Join Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn --- cli/command/manifest/rm.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cli/command/manifest/rm.go b/cli/command/manifest/rm.go index ccb6044341..e59b716cd3 100644 --- a/cli/command/manifest/rm.go +++ b/cli/command/manifest/rm.go @@ -2,12 +2,11 @@ package manifest import ( "context" - "strings" + "errors" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" manifeststore "github.com/docker/cli/cli/manifest/store" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -25,28 +24,25 @@ func newRmManifestListCommand(dockerCLI command.Cli) *cobra.Command { } func runRemove(ctx context.Context, store manifeststore.Store, targets []string) error { - var errs []string + var errs []error for _, target := range targets { if ctx.Err() != nil { return ctx.Err() } targetRef, err := normalizeReference(target) if err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) continue } _, err = store.GetList(targetRef) if err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) continue } err = store.Remove(targetRef) if err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) } } - if len(errs) > 0 { - return errors.New(strings.Join(errs, "\n")) - } - return nil + return errors.Join(errs...) }