updating registry client

feature/registry-client-fix-371
Karolis Rusenas 2019-04-25 22:03:04 +01:00
parent ff533520e1
commit 1ddff96636
3 changed files with 28 additions and 2 deletions

2
Gopkg.lock generated
View File

@ -442,7 +442,7 @@
branch = "master"
name = "github.com/rusenask/docker-registry-client"
packages = ["registry"]
revision = "2f0bd62922f141c5301ccbd30d93528ebbe73f41"
revision = "f41c43a13c3852213e225cc2476800c8f734d777"
[[projects]]
branch = "master"

View File

@ -7,6 +7,8 @@ import (
"github.com/keel-hq/keel/constants"
"github.com/rusenask/docker-registry-client/registry"
"fmt"
"os"
"testing"
@ -302,3 +304,15 @@ var tagsResp = `{
"master-3945"
]
}`
func TestGetDockerHubManyTags(t *testing.T) {
client := registry.New("https://quay.io", "", "")
tags, err := client.Tags("coreos/prometheus-operator")
if err != nil {
t.Errorf("error while getting repo: %s", err)
}
fmt.Println(tags)
}

View File

@ -3,8 +3,10 @@ package registry
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"strings"
)
var (
@ -31,6 +33,7 @@ func (registry *Registry) getJson(url string, response interface{}) error {
// next page URL while updating pointed-to variable with a parsed JSON
// value. When there are no more pages it returns `ErrNoMorePages`.
func (registry *Registry) getPaginatedJson(url string, response interface{}) (string, error) {
fmt.Println("getting: ", url)
resp, err := registry.Client.Get(url)
if err != nil {
return "", err
@ -42,7 +45,16 @@ func (registry *Registry) getPaginatedJson(url string, response interface{}) (st
if err != nil {
return "", err
}
return getNextLink(resp)
next, err := getNextLink(resp)
if err != nil {
return "", err
}
if !strings.HasPrefix(next, registry.URL) {
next = registry.URL + next
}
return next, nil
}
// Matches an RFC 5988 (https://tools.ietf.org/html/rfc5988#section-5)