Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

support registry:2.7 +, fix https://github.com/heroku/docker-registry-client/issues/82 #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion registry/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package registry
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"strings"
)

var (
Expand Down Expand Up @@ -33,7 +35,8 @@ func (registry *Registry) getPaginatedJSON(url string, response interface{}) (st
// Link header. For example,
//
// <http://registry.example.com/v2/_catalog?n=5&last=tag5>; type="application/json"; rel="next"
//
// 2.7 will be
// </v2/_catalog?n=5&last=tag5>; type="application/json"; rel="next"
// The URL is _supposed_ to be wrapped by angle brackets `< ... >`,
// but e.g., quay.io does not include them. Similarly, params like
// `rel="next"` may not have quoted values in the wild.
Expand All @@ -43,6 +46,10 @@ func getNextLink(resp *http.Response) (string, error) {
for _, link := range resp.Header[http.CanonicalHeaderKey("Link")] {
parts := nextLinkRE.FindStringSubmatch(link)
if parts != nil {
// support 2.7+ distribution
if strings.HasPrefix(parts[1], "/") {
return fmt.Sprintf("%s://%s%s", resp.Request.URL.Scheme, resp.Request.URL.Host, parts[1]), nil
}
return parts[1], nil
}
}
Expand Down