cli/command/config: RunConfigRemove: 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
ce30966636
commit
791e06b435
@ -2,12 +2,11 @@ package config
|
|||||||
|
|
||||||
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/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,23 +34,17 @@ func newConfigRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RunConfigRemove removes the given Swarm configs.
|
// RunConfigRemove removes the given Swarm configs.
|
||||||
func RunConfigRemove(ctx context.Context, dockerCli command.Cli, opts RemoveOptions) error {
|
func RunConfigRemove(ctx context.Context, dockerCLI command.Cli, opts RemoveOptions) error {
|
||||||
client := dockerCli.Client()
|
apiClient := dockerCLI.Client()
|
||||||
|
|
||||||
var errs []string
|
|
||||||
|
|
||||||
|
var errs []error
|
||||||
for _, name := range opts.Names {
|
for _, name := range opts.Names {
|
||||||
if err := client.ConfigRemove(ctx, name); err != nil {
|
if err := apiClient.ConfigRemove(ctx, name); err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
|
||||||
fmt.Fprintln(dockerCli.Out(), name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
return errors.Join(errs...)
|
||||||
return errors.Errorf("%s", strings.Join(errs, "\n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user