mirror of https://github.com/docker/cli.git
Merge pull request #3705 from thaJeztah/no_unauthorized
remove uses of client.IsErrUnauthorized()
This commit is contained in:
commit
3564b7d375
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
registrytypes "github.com/docker/docker/api/types/registry"
|
registrytypes "github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -168,7 +169,7 @@ func loginWithCredStoreCreds(ctx context.Context, dockerCli command.Cli, authCon
|
||||||
cliClient := dockerCli.Client()
|
cliClient := dockerCli.Client()
|
||||||
response, err := cliClient.RegistryLogin(ctx, *authConfig)
|
response, err := cliClient.RegistryLogin(ctx, *authConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsErrUnauthorized(err) {
|
if errdefs.IsUnauthorized(err) {
|
||||||
fmt.Fprintf(dockerCli.Err(), "Stored credentials invalid or expired\n")
|
fmt.Fprintf(dockerCli.Err(), "Stored credentials invalid or expired\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(dockerCli.Err(), "Login did not succeed, error: %s\n", err)
|
fmt.Fprintf(dockerCli.Err(), "Login did not succeed, error: %s\n", err)
|
||||||
|
|
|
@ -64,8 +64,6 @@ func TestLoginWithCredStoreCreds(t *testing.T) {
|
||||||
expectedMsg: "Authenticating with existing credentials...\n",
|
expectedMsg: "Authenticating with existing credentials...\n",
|
||||||
expectedErr: fmt.Sprintf("Login did not succeed, error: %s\n", testAuthErrMsg),
|
expectedErr: fmt.Sprintf("Login did not succeed, error: %s\n", testAuthErrMsg),
|
||||||
},
|
},
|
||||||
// can't easily test the 401 case because client.IsErrUnauthorized(err) involving
|
|
||||||
// creating an error of a private type
|
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
|
Loading…
Reference in New Issue