working commit
This commit is contained in:
+24
-12
@@ -15,16 +15,17 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
MediaTypeOIIv1 = "application/vnd.oci.image.index.v1+json"
|
||||
MediaTypeDDMLv2 = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
//MediaTypeOIIv1 = "application/vnd.oci.image.index.v1+json"
|
||||
//MediaTypeDDMLv2 = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
|
||||
MediaTypeDDMv2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
MediaTypeOIMv1 = "application/vnd.oci.image.manifest.v1+json"
|
||||
// MediaTypeDDMv2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
// MediaTypeOIMv1 = "application/vnd.oci.image.manifest.v1+json"
|
||||
)
|
||||
|
||||
type Loader struct {
|
||||
@@ -39,13 +40,25 @@ func NewLoader(client *Client) *Loader {
|
||||
|
||||
func (down *Loader) Pull(ctx context.Context, rawref, dir, osname, arch string) error {
|
||||
var err error
|
||||
if osname == "" {
|
||||
osname = runtime.GOOS
|
||||
}
|
||||
if arch == "" {
|
||||
arch = runtime.GOARCH
|
||||
}
|
||||
|
||||
ref, err := NewReferer(rawref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rawrepo := ref.RawRepo()
|
||||
|
||||
exist, mime, man, digstr, err := down.cli.GetRawManifest(ctx, ref.Raw())
|
||||
accepts := []string{
|
||||
MediaTypeDDMLv2,
|
||||
MediaTypeDDMv2,
|
||||
MediaTypeOIMv1,
|
||||
MediaTypeOIIv1,
|
||||
}
|
||||
exist, mime, man, digstr, err := down.cli.GetRawManifest(ctx, ref.Raw(), accepts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,13 +87,12 @@ func (down *Loader) Pull(ctx context.Context, rawref, dir, osname, arch string)
|
||||
err = errors.New("Manifest for required arch and OS not found")
|
||||
return err
|
||||
}
|
||||
|
||||
exist, mime, man, digstr, err = down.cli.GetRawManifest(ctx, ref.RawWithTag(tag))
|
||||
if err != nil {
|
||||
return err
|
||||
accepts := []string{
|
||||
MediaTypeDDMv2,
|
||||
MediaTypeOIMv1,
|
||||
}
|
||||
if !exist {
|
||||
err = errors.New("Manifest not found")
|
||||
_, mime, man, digstr, err = down.cli.GetRawManifest(ctx, ref.RawWithTag(tag), accepts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if mime != MediaTypeOIMv1 && mime != MediaTypeDDMv2 {
|
||||
|
||||
Reference in New Issue
Block a user