1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #43571 from crazy-max/vendor-buildkit-0.10.3

vendor: github.com/moby/buildkit v0.10.3
This commit is contained in:
Sebastiaan van Stijn 2022-05-20 02:11:35 +02:00 committed by GitHub
commit 2cfbb039d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 25 deletions

View file

@ -124,7 +124,9 @@ jobs:
name: BuildKit ref
run: |
./hack/go-mod-prepare.sh
echo "BUILDKIT_REF=$(./hack/buildkit-ref)" >> $GITHUB_ENV
echo "BUILDKIT_REF=0da740f7d4f782a52b416a44f564ac37504b9ee1" >> $GITHUB_ENV
# FIXME(thaJeztah) temporarily overriding version to use for tests to include https://github.com/moby/buildkit/pull/2872
# echo "BUILDKIT_REF=$(./hack/buildkit-ref)" >> $GITHUB_ENV
working-directory: moby
-
name: Checkout BuildKit ${{ env.BUILDKIT_REF }}

View file

@ -48,7 +48,7 @@ require (
github.com/klauspost/compress v1.15.1
github.com/miekg/dns v1.1.27
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible
github.com/moby/buildkit v0.10.2
github.com/moby/buildkit v0.10.3 // FIXME(thaJeztah) when updating, remove the temporary override in /.github/workflows/ci.yml
github.com/moby/ipvs v1.0.1
github.com/moby/locker v1.0.1
github.com/moby/swarmkit/v2 v2.0.0-20220420172245-6068d1894d46

View file

@ -725,8 +725,8 @@ github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A=
github.com/moby/buildkit v0.10.2 h1:jywa+mPPtsfCQqpIbt72RUKf49hTTCirTqIs4LG0n+8=
github.com/moby/buildkit v0.10.2/go.mod h1:jxeOuly98l9gWHai0Ojrbnczrk/rf+o9/JqNhY+UCSo=
github.com/moby/buildkit v0.10.3 h1:/dGykD8FW+H4p++q5+KqKEo6gAkYKyBQHdawdjVwVAU=
github.com/moby/buildkit v0.10.3/go.mod h1:jxeOuly98l9gWHai0Ojrbnczrk/rf+o9/JqNhY+UCSo=
github.com/moby/ipvs v1.0.1 h1:aoZ7fhLTXgDbzVrAnvV+XbKOU8kOET7B3+xULDF/1o0=
github.com/moby/ipvs v1.0.1/go.mod h1:2pngiyseZbIKXNv7hsKj3O9UEz30c53MT9005gt2hxQ=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=

View file

@ -812,8 +812,8 @@ func warnOpts(sm *llb.SourceMap, r *parser.Range, detail [][]byte, url string) c
return opts
}
func contextByNameFunc(c client.Client, p *ocispecs.Platform) func(context.Context, string) (*llb.State, *dockerfile2llb.Image, *binfotypes.BuildInfo, error) {
return func(ctx context.Context, name string) (*llb.State, *dockerfile2llb.Image, *binfotypes.BuildInfo, error) {
func contextByNameFunc(c client.Client, p *ocispecs.Platform) func(context.Context, string, string) (*llb.State, *dockerfile2llb.Image, *binfotypes.BuildInfo, error) {
return func(ctx context.Context, name, resolveMode string) (*llb.State, *dockerfile2llb.Image, *binfotypes.BuildInfo, error) {
named, err := reference.ParseNormalizedNamed(name)
if err != nil {
return nil, nil, nil, errors.Wrapf(err, "invalid context name %s", name)
@ -826,7 +826,7 @@ func contextByNameFunc(c client.Client, p *ocispecs.Platform) func(context.Conte
}
if p != nil {
name := name + "::" + platforms.Format(platforms.Normalize(*p))
st, img, bi, err := contextByName(ctx, c, name, p)
st, img, bi, err := contextByName(ctx, c, name, p, resolveMode)
if err != nil {
return nil, nil, nil, err
}
@ -834,11 +834,11 @@ func contextByNameFunc(c client.Client, p *ocispecs.Platform) func(context.Conte
return st, img, bi, nil
}
}
return contextByName(ctx, c, name, p)
return contextByName(ctx, c, name, p, resolveMode)
}
}
func contextByName(ctx context.Context, c client.Client, name string, platform *ocispecs.Platform) (*llb.State, *dockerfile2llb.Image, *binfotypes.BuildInfo, error) {
func contextByName(ctx context.Context, c client.Client, name string, platform *ocispecs.Platform, resolveMode string) (*llb.State, *dockerfile2llb.Image, *binfotypes.BuildInfo, error) {
opts := c.BuildOpts().Opts
v, ok := opts["context:"+name]
if !ok {
@ -854,13 +854,38 @@ func contextByName(ctx context.Context, c client.Client, name string, platform *
ref := strings.TrimPrefix(vv[1], "//")
imgOpt := []llb.ImageOption{
llb.WithCustomName("[context " + name + "] " + ref),
llb.WithMetaResolver(c),
}
if platform != nil {
imgOpt = append(imgOpt, llb.Platform(*platform))
}
named, err := reference.ParseNormalizedNamed(ref)
if err != nil {
return nil, nil, nil, err
}
named = reference.TagNameOnly(named)
_, data, err := c.ResolveImageConfig(ctx, named.String(), llb.ResolveImageConfigOpt{
Platform: platform,
ResolveMode: resolveMode,
LogName: fmt.Sprintf("[context %s] load metadata for %s", name, ref),
})
if err != nil {
return nil, nil, nil, err
}
var img dockerfile2llb.Image
if err := json.Unmarshal(data, &img); err != nil {
return nil, nil, nil, err
}
st := llb.Image(ref, imgOpt...)
return &st, nil, nil, nil
st, err = st.WithImageConfig(data)
if err != nil {
return nil, nil, nil, err
}
return &st, &img, nil, nil
case "git":
st, ok := detectGitContext(v, "1")
if !ok {

View file

@ -70,16 +70,16 @@ type ConvertOpt struct {
SourceMap *llb.SourceMap
Hostname string
Warn func(short, url string, detail [][]byte, location *parser.Range)
ContextByName func(context.Context, string) (*llb.State, *Image, *binfotypes.BuildInfo, error)
ContextByName func(ctx context.Context, name, resolveMode string) (*llb.State, *Image, *binfotypes.BuildInfo, error)
}
func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State, *Image, *binfotypes.BuildInfo, error) {
buildInfo := &binfotypes.BuildInfo{}
contextByName := opt.ContextByName
opt.ContextByName = func(ctx context.Context, name string) (*llb.State, *Image, *binfotypes.BuildInfo, error) {
opt.ContextByName = func(ctx context.Context, name, resolveMode string) (*llb.State, *Image, *binfotypes.BuildInfo, error) {
if !strings.EqualFold(name, "scratch") && !strings.EqualFold(name, "context") {
if contextByName != nil {
st, img, bi, err := contextByName(ctx, name)
st, img, bi, err := contextByName(ctx, name, resolveMode)
if err != nil {
return nil, nil, nil, err
}
@ -166,7 +166,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
}
if st.Name != "" {
s, img, bi, err := opt.ContextByName(ctx, st.Name)
s, img, bi, err := opt.ContextByName(ctx, st.Name, opt.ImageResolveMode.String())
if err != nil {
return nil, nil, nil, err
}
@ -313,7 +313,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
d.stage.BaseName = reference.TagNameOnly(ref).String()
var isScratch bool
st, img, bi, err := opt.ContextByName(ctx, d.stage.BaseName)
st, img, bi, err := opt.ContextByName(ctx, d.stage.BaseName, opt.ImageResolveMode.String())
if err != nil {
return err
}

View file

@ -26,7 +26,7 @@ import (
)
func llbBridgeToGatewayClient(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*opspb.Definition, w worker.Infos, sid string, sm *session.Manager) (*bridgeClient, error) {
return &bridgeClient{
bc := &bridgeClient{
opts: opts,
inputs: inputs,
FrontendLLBBridge: llbBridge,
@ -35,7 +35,9 @@ func llbBridgeToGatewayClient(ctx context.Context, llbBridge frontend.FrontendLL
workers: w,
final: map[*ref]struct{}{},
workerRefByID: make(map[string]*worker.WorkerRef),
}, nil
}
bc.buildOpts = bc.loadBuildOpts()
return bc, nil
}
type bridgeClient struct {
@ -49,6 +51,7 @@ type bridgeClient struct {
refs []*ref
workers worker.Infos
workerRefByID map[string]*worker.WorkerRef
buildOpts client.BuildOpts
}
func (c *bridgeClient) Solve(ctx context.Context, req client.SolveRequest) (*client.Result, error) {
@ -87,14 +90,15 @@ func (c *bridgeClient) Solve(ctx context.Context, req client.SolveRequest) (*cli
return cRes, nil
}
func (c *bridgeClient) BuildOpts() client.BuildOpts {
workers := make([]client.WorkerInfo, 0, len(c.workers.WorkerInfos()))
for _, w := range c.workers.WorkerInfos() {
workers = append(workers, client.WorkerInfo{
func (c *bridgeClient) loadBuildOpts() client.BuildOpts {
wis := c.workers.WorkerInfos()
workers := make([]client.WorkerInfo, len(wis))
for i, w := range wis {
workers[i] = client.WorkerInfo{
ID: w.ID,
Labels: w.Labels,
Platforms: w.Platforms,
})
}
}
return client.BuildOpts{
@ -107,6 +111,10 @@ func (c *bridgeClient) BuildOpts() client.BuildOpts {
}
}
func (c *bridgeClient) BuildOpts() client.BuildOpts {
return c.buildOpts
}
func (c *bridgeClient) Inputs(ctx context.Context) (map[string]llb.State, error) {
inputs := make(map[string]llb.State)
for key, def := range c.inputs {

View file

@ -64,7 +64,7 @@ func (c *Controller) WorkerInfos() []client.WorkerInfo {
out = append(out, client.WorkerInfo{
ID: w.ID(),
Labels: w.Labels(),
Platforms: w.Platforms(true),
Platforms: w.Platforms(false),
})
}
return out

2
vendor/modules.txt vendored
View file

@ -466,7 +466,7 @@ github.com/mistifyio/go-zfs
# github.com/mitchellh/hashstructure/v2 v2.0.2
## explicit; go 1.14
github.com/mitchellh/hashstructure/v2
# github.com/moby/buildkit v0.10.2
# github.com/moby/buildkit v0.10.3
## explicit; go 1.17
github.com/moby/buildkit/api/services/control
github.com/moby/buildkit/api/types