mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
builder: buildkit rebase update
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
360d2f2ce7
commit
48b93419dc
4 changed files with 38 additions and 18 deletions
|
@ -126,7 +126,7 @@ func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string) (dige
|
||||||
dt []byte
|
dt []byte
|
||||||
}
|
}
|
||||||
res, err := is.g.Do(ctx, ref, func(ctx context.Context) (interface{}, error) {
|
res, err := is.g.Do(ctx, ref, func(ctx context.Context) (interface{}, error) {
|
||||||
dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(ctx), is.ContentStore, "")
|
dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(ctx), is.ContentStore, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/containerd/containerd/rootfs"
|
"github.com/containerd/containerd/rootfs"
|
||||||
"github.com/docker/docker/distribution"
|
"github.com/docker/docker/distribution"
|
||||||
distmetadata "github.com/docker/docker/distribution/metadata"
|
distmetadata "github.com/docker/docker/distribution/metadata"
|
||||||
|
@ -122,6 +123,12 @@ func (w *Worker) Labels() map[string]string {
|
||||||
return w.Opt.Labels
|
return w.Opt.Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Platforms returns one or more platforms supported by the image.
|
||||||
|
func (w *Worker) Platforms() []ocispec.Platform {
|
||||||
|
// does not handle lcow
|
||||||
|
return []ocispec.Platform{platforms.DefaultSpec()}
|
||||||
|
}
|
||||||
|
|
||||||
// LoadRef loads a reference by ID
|
// LoadRef loads a reference by ID
|
||||||
func (w *Worker) LoadRef(id string) (cache.ImmutableRef, error) {
|
func (w *Worker) LoadRef(id string) (cache.ImmutableRef, error) {
|
||||||
return w.CacheManager.Get(context.TODO(), id)
|
return w.CacheManager.Get(context.TODO(), id)
|
||||||
|
@ -129,26 +136,27 @@ func (w *Worker) LoadRef(id string) (cache.ImmutableRef, error) {
|
||||||
|
|
||||||
// ResolveOp converts a LLB vertex into a LLB operation
|
// ResolveOp converts a LLB vertex into a LLB operation
|
||||||
func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solver.Op, error) {
|
func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solver.Op, error) {
|
||||||
switch op := v.Sys().(type) {
|
if baseOp, ok := v.Sys().(*pb.Op); ok {
|
||||||
|
switch op := baseOp.Op.(type) {
|
||||||
case *pb.Op_Source:
|
case *pb.Op_Source:
|
||||||
return ops.NewSourceOp(v, op, w.SourceManager, w)
|
return ops.NewSourceOp(v, op, baseOp.Platform, w.SourceManager, w)
|
||||||
case *pb.Op_Exec:
|
case *pb.Op_Exec:
|
||||||
return ops.NewExecOp(v, op, w.CacheManager, w.MetadataStore, w.Executor, w)
|
return ops.NewExecOp(v, op, w.CacheManager, w.MetadataStore, w.Executor, w)
|
||||||
case *pb.Op_Build:
|
case *pb.Op_Build:
|
||||||
return ops.NewBuildOp(v, op, s, w)
|
return ops.NewBuildOp(v, op, s, w)
|
||||||
default:
|
|
||||||
return nil, errors.Errorf("could not resolve %v", v)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return nil, errors.Errorf("could not resolve %v", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveImageConfig returns image config for an image
|
// ResolveImageConfig returns image config for an image
|
||||||
func (w *Worker) ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error) {
|
func (w *Worker) ResolveImageConfig(ctx context.Context, ref string, platform *ocispec.Platform) (digest.Digest, []byte, error) {
|
||||||
// ImageSource is typically source/containerimage
|
// ImageSource is typically source/containerimage
|
||||||
resolveImageConfig, ok := w.ImageSource.(resolveImageConfig)
|
resolveImageConfig, ok := w.ImageSource.(resolveImageConfig)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", nil, errors.Errorf("worker %q does not implement ResolveImageConfig", w.ID())
|
return "", nil, errors.Errorf("worker %q does not implement ResolveImageConfig", w.ID())
|
||||||
}
|
}
|
||||||
return resolveImageConfig.ResolveImageConfig(ctx, ref)
|
return resolveImageConfig.ResolveImageConfig(ctx, ref, platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes a process directly on a worker
|
// Exec executes a process directly on a worker
|
||||||
|
@ -319,5 +327,5 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type resolveImageConfig interface {
|
type resolveImageConfig interface {
|
||||||
ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
|
ResolveImageConfig(ctx context.Context, ref string, platform *ocispec.Platform) (digest.Digest, []byte, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,12 +152,23 @@ func (d *dispatchRequest) getImageMount(imageRefOrID string) (*imageMount, error
|
||||||
//
|
//
|
||||||
func initializeStage(d dispatchRequest, cmd *instructions.Stage) error {
|
func initializeStage(d dispatchRequest, cmd *instructions.Stage) error {
|
||||||
d.builder.imageProber.Reset()
|
d.builder.imageProber.Reset()
|
||||||
//TODO(@arm64b): Leave the sanity check of the spec platform to the containerd code
|
|
||||||
if err := platforms.ValidatePlatform(&cmd.Platform); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
image, err := d.getFromImage(d.shlex, cmd.BaseName, cmd.Platform.OS)
|
// TODO: pass *platform instead, allow autodetect
|
||||||
|
platform := platforms.DefaultSpec()
|
||||||
|
if v := cmd.Platform; v != "" {
|
||||||
|
// TODO:
|
||||||
|
// v, err := shlex.ProcessWord(v, toEnvList(metaArgs, nil))
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, nil, errors.Wrapf(err, "failed to process arguments for platform %s", v)
|
||||||
|
// }
|
||||||
|
|
||||||
|
p, err := platforms.Parse(v)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to parse platform %s", v)
|
||||||
|
}
|
||||||
|
platform = p
|
||||||
|
}
|
||||||
|
image, err := d.getFromImage(d.shlex, cmd.BaseName, platform.OS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package system // import "github.com/docker/docker/pkg/system"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsOSSupported determines if an operating system is supported by the host
|
// IsOSSupported determines if an operating system is supported by the host
|
||||||
|
|
Loading…
Add table
Reference in a new issue