Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Use hashicorp/go-multierror in app rm
Browse files Browse the repository at this point in the history
Use hashicorp/go-multierror to handle multiple errors when removing multiple apps at once

Signed-off-by: Nick Adcock <[email protected]>
  • Loading branch information
zappy-shu committed Dec 2, 2019
1 parent 4b39e99 commit 518754b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions internal/commands/remove.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package commands

import (
"errors"
"fmt"
"os"
"strings"

"github.com/docker/app/internal/cliopts"
"github.com/docker/app/internal/cnab"
Expand All @@ -17,6 +15,7 @@ import (
"github.com/deislabs/cnab-go/credentials"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
multierror "github.com/hashicorp/go-multierror"
"github.com/spf13/cobra"
)

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

errs := []string{}
var failures *multierror.Error
for _, arg := range args {
if err := runRemove(dockerCli, arg, opts, installerContext, installationStore, credentialStore); err != nil {
errs = append(errs, fmt.Sprintf("Error: %s", err))
failures = multierror.Append(failures, err)
}
}
if len(errs) > 0 {
return errors.New(strings.Join(errs, "\n"))
}
return nil
return failures.ErrorOrNil()
},
}
opts.credentialOptions.addFlags(cmd.Flags())
Expand Down

0 comments on commit 518754b

Please sign in to comment.