cli/command/manifest: use errors.Join
Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1fd9d0dd34
commit
f8729c6da2
@ -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...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user