client rebuilding in progress
This commit is contained in:
@@ -87,8 +87,10 @@ func newBasicAuthMW(next http.RoundTripper, user, pass string) *BasicAuthMW {
|
||||
}
|
||||
|
||||
func (tran BasicAuthMW) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
pair := base64.StdEncoding.EncodeToString([]byte(tran.user + ":" + tran.pass))
|
||||
req.Header.Set("Authorization", "Basic "+pair)
|
||||
if tran.user != "" && tran.pass != "" {
|
||||
pair := base64.StdEncoding.EncodeToString([]byte(tran.user + ":" + tran.pass))
|
||||
req.Header.Set("Authorization", "Basic "+pair)
|
||||
}
|
||||
return tran.next.RoundTrip(req)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func xxxTestClientGetManifest(t *testing.T) {
|
||||
func TestClientGetManifest(t *testing.T) {
|
||||
rawrepo := "mirror.gcr.io/alpine"
|
||||
tags := []string{
|
||||
"3.20.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package repocli
|
||||
|
||||
const (
|
||||
MediaTypeDDMLv2 = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
MediaTypeDDMv2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
//MediaTypeDDMLv2 = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
//MediaTypeDDMv2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
)
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
|
||||
const (
|
||||
MediaTypeOIIv1 = "application/vnd.oci.image.index.v1+json"
|
||||
MediatypeDDMLv2 = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
MediaTypeDDMLv2 = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
|
||||
MediatypeDDMv2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
MediaTypeDDMv2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
MediaTypeOIMv1 = "application/vnd.oci.image.manifest.v1+json"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ func NewDownloader(client *Client) *Downloader {
|
||||
|
||||
func (down *Downloader) Pull(ctx context.Context, rawref, dir, os, arch string) error {
|
||||
var err error
|
||||
ref, err := NewReference(rawref)
|
||||
ref, err := ParseReference(rawref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (down *Downloader) Pull(ctx context.Context, rawref, dir, os, arch string)
|
||||
return err
|
||||
}
|
||||
|
||||
if mime == MediaTypeOIIv1 || mime == MediatypeDDMLv2 {
|
||||
if mime == MediaTypeOIIv1 || mime == MediaTypeDDMLv2 {
|
||||
var index ocispec.Index
|
||||
err = json.Unmarshal(man, &index)
|
||||
if err != nil {
|
||||
@@ -72,7 +72,7 @@ func (down *Downloader) Pull(ctx context.Context, rawref, dir, os, arch string)
|
||||
err = errors.New("Manifest not found")
|
||||
return err
|
||||
}
|
||||
if mime != MediaTypeOIMv1 && mime != MediatypeDDMv2 {
|
||||
if mime != MediaTypeOIMv1 && mime != MediaTypeDDMv2 {
|
||||
err = errors.New("Unknown manifest media type")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type Reference struct {
|
||||
base, tag string
|
||||
}
|
||||
|
||||
func NewReference(rawref string) (*Reference, error) {
|
||||
func ParseReference(rawref string) (*Reference, error) {
|
||||
ref := &Reference{}
|
||||
if !strings.Contains(rawref, "://") {
|
||||
rawref = "https://" + rawref
|
||||
@@ -54,3 +54,7 @@ func (ref *Reference) Repo() string {
|
||||
func (ref *Reference) Tag() string {
|
||||
return ref.tag
|
||||
}
|
||||
|
||||
func (ref *Reference) Userinfo() (string, string) {
|
||||
return ref.user, ref.pass
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user