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