cli/command/volume: 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
be985bd28e
commit
aa96cb7aa0
@ -2,13 +2,12 @@ package volume
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,18 +42,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
|||||||
func runRemove(ctx context.Context, dockerCLI command.Cli, opts *removeOptions) error {
|
func runRemove(ctx context.Context, dockerCLI command.Cli, opts *removeOptions) error {
|
||||||
apiClient := dockerCLI.Client()
|
apiClient := dockerCLI.Client()
|
||||||
|
|
||||||
var errs []string
|
var errs []error
|
||||||
|
|
||||||
for _, name := range opts.volumes {
|
for _, name := range opts.volumes {
|
||||||
if err := apiClient.VolumeRemove(ctx, name, opts.force); err != nil {
|
if err := apiClient.VolumeRemove(ctx, name, opts.force); err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
|
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
|
||||||
}
|
}
|
||||||
|
return errors.Join(errs...)
|
||||||
if len(errs) > 0 {
|
|
||||||
return errors.Errorf("%s", strings.Join(errs, "\n"))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user