mirror of
https://github.com/docker/compose.git
synced 2026-08-27 03:45:29 +00:00
Merge pull request #325 from docker/error_status_context_needs_login
Specific exit code when command fails because azure login is required
This commit is contained in:
commit
ae76e0cf27
4 changed files with 32 additions and 3 deletions
14
cli/main.go
14
cli/main.go
|
|
@ -27,6 +27,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/docker/api/errdefs"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -174,15 +176,23 @@ func main() {
|
|||
// Context should always be handled by new CLI
|
||||
requiredCmd, _, _ := root.Find(os.Args[1:])
|
||||
if requiredCmd != nil && isOwnCommand(requiredCmd) {
|
||||
fatal(err)
|
||||
exit(err)
|
||||
}
|
||||
mobycli.ExecIfDefaultCtxType(ctx)
|
||||
|
||||
checkIfUnknownCommandExistInDefaultContext(err, currentContext)
|
||||
fatal(err)
|
||||
exit(err)
|
||||
}
|
||||
}
|
||||
|
||||
func exit(err error) {
|
||||
if errors.Is(err, errdefs.ErrLoginRequired) {
|
||||
fmt.Fprintln(os.Stderr, fmt.Errorf("%v", err))
|
||||
os.Exit(errdefs.ExitCodeLoginRequired)
|
||||
}
|
||||
fatal(err)
|
||||
}
|
||||
|
||||
func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string) {
|
||||
submatch := unknownCommandRegexp.FindSubmatch([]byte(err.Error()))
|
||||
if len(submatch) == 2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue