Skip to content

Commit 2a9fd4a

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

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

cli/command/node/remove.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package node
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
6-
"strings"
77

88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/docker/api/types"
11-
"github.com/pkg/errors"
1211
"github.com/spf13/cobra"
1312
)
1413

@@ -36,20 +35,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
3635
func runRemove(ctx context.Context, dockerCLI command.Cli, nodeIDs []string, opts removeOptions) error {
3736
apiClient := dockerCLI.Client()
3837

39-
var errs []string
40-
38+
var errs []error
4139
for _, id := range nodeIDs {
42-
err := apiClient.NodeRemove(ctx, id, types.NodeRemoveOptions{Force: opts.force})
43-
if err != nil {
44-
errs = append(errs, err.Error())
40+
if err := apiClient.NodeRemove(ctx, id, types.NodeRemoveOptions{Force: opts.force}); err != nil {
41+
errs = append(errs, err)
4542
continue
4643
}
4744
_, _ = fmt.Fprintln(dockerCLI.Out(), id)
4845
}
49-
50-
if len(errs) > 0 {
51-
return errors.Errorf("%s", strings.Join(errs, "\n"))
52-
}
53-
54-
return nil
46+
return errors.Join(errs...)
5547
}

0 commit comments

Comments
 (0)