mirror of
https://github.com/docker/compose.git
synced 2026-08-04 14:47:40 +00:00
Azure: Refactor login errors
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
parent
35789ace12
commit
e5335adedd
4 changed files with 22 additions and 22 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package login
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import (
|
|||
|
||||
"github.com/docker/api/cli/dockerclassic"
|
||||
"github.com/docker/api/client"
|
||||
"github.com/docker/api/errdefs"
|
||||
)
|
||||
|
||||
// Command returns the login command
|
||||
|
|
@ -46,15 +48,15 @@ func cloudLogin(cmd *cobra.Command, backendType string) error {
|
|||
ctx := cmd.Context()
|
||||
cs, err := client.GetCloudService(ctx, backendType)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "cannot connect to backend")
|
||||
return errors.Wrap(errdefs.ErrLoginFailed, "cannot connect to backend")
|
||||
}
|
||||
err = cs.Login(ctx, nil)
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return errors.New("login canceled")
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cmd.Context().Err() != nil {
|
||||
return errors.New("login canceled")
|
||||
}
|
||||
fmt.Println("login successful")
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue