1
0
mirror of https://github.com/distribution/distribution synced 2024-11-12 05:45:51 +01:00

registry: use const for status code 429

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-06-08 10:19:15 +02:00
parent 596ca8b86a
commit 4901f1b278
2 changed files with 2 additions and 8 deletions

@ -71,10 +71,7 @@ var (
Message: "too many requests", Message: "too many requests",
Description: `Returned when a client attempts to contact a Description: `Returned when a client attempts to contact a
service too many times`, service too many times`,
// FIXME: go1.5 doesn't export http.StatusTooManyRequests while HTTPStatusCode: http.StatusTooManyRequests,
// go1.6 does. Update the hardcoded value to the constant once
// Docker updates golang version to 1.6.
HTTPStatusCode: 429,
}) })
) )

@ -54,10 +54,7 @@ func parseHTTPErrorResponse(statusCode int, r io.Reader) error {
switch statusCode { switch statusCode {
case http.StatusUnauthorized: case http.StatusUnauthorized:
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details) return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
// FIXME: go1.5 doesn't export http.StatusTooManyRequests while case http.StatusTooManyRequests:
// go1.6 does. Update the hardcoded value to the constant once
// Docker updates golang version to 1.6.
case 429:
return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details) return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details)
default: default:
return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details) return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details)