mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 08:57:44 +08:00
Merge pull request #68 from tonistiigi/arm-variant
imagetools: keep arm variant
This commit is contained in:
commit
b3fe1a333d
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/specs-go"
|
"github.com/opencontainers/image-spec/specs-go"
|
||||||
@ -47,14 +48,11 @@ func (r *Resolver) Combine(ctx context.Context, in string, descs []ocispec.Descr
|
|||||||
switch mt {
|
switch mt {
|
||||||
case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest:
|
case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest:
|
||||||
if descs[i].Platform == nil {
|
if descs[i].Platform == nil {
|
||||||
cfg, err := r.loadConfig(ctx, in, dt)
|
p, err := r.loadPlatform(ctx, in, dt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
descs[i].Platform = &ocispec.Platform{
|
descs[i].Platform = p
|
||||||
OS: cfg.OS,
|
|
||||||
Architecture: cfg.Architecture,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case images.MediaTypeDockerSchema1Manifest:
|
case images.MediaTypeDockerSchema1Manifest:
|
||||||
return errors.Errorf("schema1 manifests are not allowed in manifest lists")
|
return errors.Errorf("schema1 manifests are not allowed in manifest lists")
|
||||||
@ -168,7 +166,7 @@ func (r *Resolver) Push(ctx context.Context, ref reference.Named, desc ocispec.D
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) loadConfig(ctx context.Context, in string, dt []byte) (*ocispec.Image, error) {
|
func (r *Resolver) loadPlatform(ctx context.Context, in string, dt []byte) (*ocispec.Platform, error) {
|
||||||
var manifest ocispec.Manifest
|
var manifest ocispec.Manifest
|
||||||
if err := json.Unmarshal(dt, &manifest); err != nil {
|
if err := json.Unmarshal(dt, &manifest); err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
@ -179,12 +177,13 @@ func (r *Resolver) loadConfig(ctx context.Context, in string, dt []byte) (*ocisp
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var img ocispec.Image
|
var p ocispec.Platform
|
||||||
if err := json.Unmarshal(dt, &img); err != nil {
|
if err := json.Unmarshal(dt, &p); err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &img, nil
|
p = platforms.Normalize(p)
|
||||||
|
return &p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectMediaType(dt []byte) (string, error) {
|
func detectMediaType(dt []byte) (string, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user