1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

registry.Auth: try next endpoints on non-auth failures

Allow falling back to non-TLS endpoints if present.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-12-07 16:09:05 +01:00
parent 588da41f52
commit 80cc1f1d6f
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -131,7 +131,15 @@ func (s *DefaultService) Auth(ctx context.Context, authConfig *types.AuthConfig,
}
for _, endpoint := range endpoints {
return loginV2(authConfig, endpoint, userAgent)
status, token, err = loginV2(authConfig, endpoint, userAgent)
if err == nil {
return
}
if errdefs.IsUnauthorized(err) {
// Failed to authenticate; don't continue with (non-TLS) endpoints.
return status, token, err
}
logrus.WithError(err).Infof("Error logging in to endpoint, trying next endpoint")
}
return "", "", err