Skip to content

Commit c5f869f

Browse files
committed
docker: fix unauthenticated pulls from gcr.io
Signed-off-by: Antonio Murdaca <[email protected]>
1 parent 514da4b commit c5f869f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docker/docker_client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ func (c *dockerClient) setupRequestAuth(req *http.Request) error {
265265
}
266266
chs := parseAuthHeader(res.Header)
267267
if res.StatusCode != http.StatusUnauthorized || chs == nil || len(chs) == 0 {
268-
// try again one last time with Basic Auth (gcr.io for instance)
268+
if res.StatusCode == http.StatusOK {
269+
return nil // gcr.io unauthenticated pull
270+
}
271+
// gcr.io authenticated pull requires us to send user:pass pair in
272+
// order to retrieve a token
273+
// try again one last time with Basic Auth
269274
testReq2 := *req
270275
// Do not use the body stream, or we couldn't reuse it for the "real" call later.
271276
testReq2.Body = nil

0 commit comments

Comments
 (0)