mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: github.com/moby/buildkit v0.21.0-rc1
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
31
vendor/github.com/moby/buildkit/frontend/dockerui/build.go
generated
vendored
31
vendor/github.com/moby/buildkit/frontend/dockerui/build.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/containerd/platforms"
|
||||
"github.com/moby/buildkit/exporter/containerimage/exptypes"
|
||||
@ -54,23 +55,16 @@ func (bc *Client) Build(ctx context.Context, fn BuildFunc) (*ResultBuilder, erro
|
||||
}
|
||||
}
|
||||
|
||||
p := platforms.DefaultSpec()
|
||||
var p ocispecs.Platform
|
||||
if tp != nil {
|
||||
p = *tp
|
||||
} else {
|
||||
p = platforms.DefaultSpec()
|
||||
}
|
||||
|
||||
// in certain conditions we allow input platform to be extended from base image
|
||||
if p.OS == "windows" && img.OS == p.OS {
|
||||
if p.OSVersion == "" && img.OSVersion != "" {
|
||||
p.OSVersion = img.OSVersion
|
||||
}
|
||||
if p.OSFeatures == nil && len(img.OSFeatures) > 0 {
|
||||
p.OSFeatures = append([]string{}, img.OSFeatures...)
|
||||
}
|
||||
}
|
||||
|
||||
p = platforms.Normalize(p)
|
||||
k := platforms.FormatAll(p)
|
||||
p = extendWindowsPlatform(p, img.Platform)
|
||||
p = platforms.Normalize(p)
|
||||
|
||||
if bc.MultiPlatformRequested {
|
||||
res.AddRef(k, ref)
|
||||
@ -126,3 +120,16 @@ func (rb *ResultBuilder) EachPlatform(ctx context.Context, fn func(ctx context.C
|
||||
}
|
||||
return eg.Wait()
|
||||
}
|
||||
|
||||
func extendWindowsPlatform(p, imgP ocispecs.Platform) ocispecs.Platform {
|
||||
// in certain conditions we allow input platform to be extended from base image
|
||||
if p.OS == "windows" && imgP.OS == p.OS {
|
||||
if p.OSVersion == "" && imgP.OSVersion != "" {
|
||||
p.OSVersion = imgP.OSVersion
|
||||
}
|
||||
if p.OSFeatures == nil && len(imgP.OSFeatures) > 0 {
|
||||
p.OSFeatures = slices.Clone(imgP.OSFeatures)
|
||||
}
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
8
vendor/github.com/moby/buildkit/frontend/dockerui/config.go
generated
vendored
8
vendor/github.com/moby/buildkit/frontend/dockerui/config.go
generated
vendored
@ -148,9 +148,11 @@ func (bc *Client) BuildOpts() client.BuildOpts {
|
||||
func (bc *Client) init() error {
|
||||
opts := bc.bopts.Opts
|
||||
|
||||
defaultBuildPlatform := platforms.Normalize(platforms.DefaultSpec())
|
||||
var defaultBuildPlatform ocispecs.Platform
|
||||
if workers := bc.bopts.Workers; len(workers) > 0 && len(workers[0].Platforms) > 0 {
|
||||
defaultBuildPlatform = workers[0].Platforms[0]
|
||||
} else {
|
||||
defaultBuildPlatform = platforms.Normalize(platforms.DefaultSpec())
|
||||
}
|
||||
buildPlatforms := []ocispecs.Platform{defaultBuildPlatform}
|
||||
targetPlatforms := []ocispecs.Platform{}
|
||||
@ -459,9 +461,11 @@ func (bc *Client) NamedContext(name string, opt ContextOpt) (*NamedContext, erro
|
||||
}
|
||||
name = strings.TrimSuffix(reference.FamiliarString(named), ":latest")
|
||||
|
||||
pp := platforms.DefaultSpec()
|
||||
var pp ocispecs.Platform
|
||||
if opt.Platform != nil {
|
||||
pp = *opt.Platform
|
||||
} else {
|
||||
pp = platforms.DefaultSpec()
|
||||
}
|
||||
pname := name + "::" + platforms.FormatAll(platforms.Normalize(pp))
|
||||
nc, err := bc.namedContext(name, pname, opt)
|
||||
|
Reference in New Issue
Block a user