@@ -2,12 +2,11 @@ package config
22
33import (
44 "context"
5+ "errors"
56 "fmt"
6- "strings"
77
88 "github.com/docker/cli/cli"
99 "github.com/docker/cli/cli/command"
10- "github.com/pkg/errors"
1110 "github.com/spf13/cobra"
1211)
1312
@@ -35,23 +34,17 @@ func newConfigRemoveCommand(dockerCli command.Cli) *cobra.Command {
3534}
3635
3736// RunConfigRemove removes the given Swarm configs.
38- func RunConfigRemove (ctx context.Context , dockerCli command.Cli , opts RemoveOptions ) error {
39- client := dockerCli .Client ()
40-
41- var errs []string
37+ func RunConfigRemove (ctx context.Context , dockerCLI command.Cli , opts RemoveOptions ) error {
38+ apiClient := dockerCLI .Client ()
4239
40+ var errs []error
4341 for _ , name := range opts .Names {
44- if err := client .ConfigRemove (ctx , name ); err != nil {
45- errs = append (errs , err . Error () )
42+ if err := apiClient .ConfigRemove (ctx , name ); err != nil {
43+ errs = append (errs , err )
4644 continue
4745 }
48-
49- fmt .Fprintln (dockerCli .Out (), name )
50- }
51-
52- if len (errs ) > 0 {
53- return errors .Errorf ("%s" , strings .Join (errs , "\n " ))
46+ _ , _ = fmt .Fprintln (dockerCLI .Out (), name )
5447 }
5548
56- return nil
49+ return errors . Join ( errs ... )
5750}
0 commit comments