diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2019-02-09 19:19:22 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2019-03-16 00:42:42 +0100 |
commit | 0cafc84fb21f675a9794c80e59f8f85919c618ec (patch) | |
tree | 94950bee3ddf1d842e9928d9a9771b8502986839 /client/image_push.go | |
parent | 053c6f097a1af7047e831094c0dfa3408a2c9d2b (diff) | |
download | docker-0cafc84fb21f675a9794c80e59f8f85919c618ec.tar.gz |
Use errdefs for handling errors in client
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'client/image_push.go')
-rw-r--r-- | client/image_push.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/client/image_push.go b/client/image_push.go index a15871c2b4..49d412ee37 100644 --- a/client/image_push.go +++ b/client/image_push.go @@ -4,11 +4,11 @@ import ( "context" "errors" "io" - "net/http" "net/url" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/errdefs" ) // ImagePush requests the docker host to push an image to a remote registry. @@ -36,7 +36,7 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options types.Im query.Set("tag", tag) resp, err := cli.tryImagePush(ctx, name, query, options.RegistryAuth) - if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil { + if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc() if privilegeErr != nil { return nil, privilegeErr |