forked from toolshed/abra
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"coopcloud.tech/abra/pkg/web"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/hashicorp/go-retryablehttp"
|
||||
)
|
||||
|
||||
type RawTag struct {
|
||||
@ -35,12 +36,12 @@ func GetRegistryTags(image string) (RawTags, error) {
|
||||
func getRegv2Token(image reference.Named) (string, error) {
|
||||
img := reference.Path(image)
|
||||
authTokenURL := fmt.Sprintf("https://auth.docker.io/token?service=registry.docker.io&scope=repository:%s:pull", img)
|
||||
req, err := http.NewRequest("GET", authTokenURL, nil)
|
||||
req, err := retryablehttp.NewRequest("GET", authTokenURL, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := &http.Client{Timeout: web.Timeout}
|
||||
client := web.NewHTTPRetryClient()
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -78,7 +79,7 @@ func GetTagDigest(image reference.Named) (string, error) {
|
||||
tag := image.(reference.NamedTagged).Tag()
|
||||
manifestURL := fmt.Sprintf("https://index.docker.io/v2/%s/manifests/%s", img, tag)
|
||||
|
||||
req, err := http.NewRequest("GET", manifestURL, nil)
|
||||
req, err := retryablehttp.NewRequest("GET", manifestURL, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -96,7 +97,7 @@ func GetTagDigest(image reference.Named) (string, error) {
|
||||
"Authorization": []string{fmt.Sprintf("Bearer %s", token)},
|
||||
}
|
||||
|
||||
client := &http.Client{Timeout: web.Timeout}
|
||||
client := web.NewHTTPRetryClient()
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
Reference in New Issue
Block a user