Skip to content

Commit f8729c6

Browse files
committed
cli/command/manifest: use errors.Join
Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 1fd9d0d commit f8729c6

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

  • cli/command/manifest

cli/command/manifest/rm.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ package manifest
22

33
import (
44
"context"
5-
"strings"
5+
"errors"
66

77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
99
manifeststore "github.com/docker/cli/cli/manifest/store"
10-
"github.com/pkg/errors"
1110
"github.com/spf13/cobra"
1211
)
1312

@@ -25,28 +24,25 @@ func newRmManifestListCommand(dockerCLI command.Cli) *cobra.Command {
2524
}
2625

2726
func runRemove(ctx context.Context, store manifeststore.Store, targets []string) error {
28-
var errs []string
27+
var errs []error
2928
for _, target := range targets {
3029
if ctx.Err() != nil {
3130
return ctx.Err()
3231
}
3332
targetRef, err := normalizeReference(target)
3433
if err != nil {
35-
errs = append(errs, err.Error())
34+
errs = append(errs, err)
3635
continue
3736
}
3837
_, err = store.GetList(targetRef)
3938
if err != nil {
40-
errs = append(errs, err.Error())
39+
errs = append(errs, err)
4140
continue
4241
}
4342
err = store.Remove(targetRef)
4443
if err != nil {
45-
errs = append(errs, err.Error())
44+
errs = append(errs, err)
4645
}
4746
}
48-
if len(errs) > 0 {
49-
return errors.New(strings.Join(errs, "\n"))
50-
}
51-
return nil
47+
return errors.Join(errs...)
5248
}

0 commit comments

Comments
 (0)