Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 518754b

Browse files
committed
Use hashicorp/go-multierror in app rm
Use hashicorp/go-multierror to handle multiple errors when removing multiple apps at once Signed-off-by: Nick Adcock <[email protected]>
1 parent 4b39e99 commit 518754b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

internal/commands/remove.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package commands
22

33
import (
4-
"errors"
54
"fmt"
65
"os"
7-
"strings"
86

97
"github.com/docker/app/internal/cliopts"
108
"github.com/docker/app/internal/cnab"
@@ -17,6 +15,7 @@ import (
1715
"github.com/deislabs/cnab-go/credentials"
1816
"github.com/docker/cli/cli"
1917
"github.com/docker/cli/cli/command"
18+
multierror "github.com/hashicorp/go-multierror"
2019
"github.com/spf13/cobra"
2120
)
2221

@@ -40,16 +39,13 @@ func removeCmd(dockerCli command.Cli, installerContext *cliopts.InstallerContext
4039
return err
4140
}
4241

43-
errs := []string{}
42+
var failures *multierror.Error
4443
for _, arg := range args {
4544
if err := runRemove(dockerCli, arg, opts, installerContext, installationStore, credentialStore); err != nil {
46-
errs = append(errs, fmt.Sprintf("Error: %s", err))
45+
failures = multierror.Append(failures, err)
4746
}
4847
}
49-
if len(errs) > 0 {
50-
return errors.New(strings.Join(errs, "\n"))
51-
}
52-
return nil
48+
return failures.ErrorOrNil()
5349
},
5450
}
5551
opts.credentialOptions.addFlags(cmd.Flags())

0 commit comments

Comments
 (0)