vendor: update buildkit

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-09-21 07:49:39 +02:00
parent 06541ebd0f
commit 45e4550c36
1040 changed files with 100774 additions and 7915 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/moby/buildkit/solver/pb"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@ -21,7 +21,7 @@ type DefinitionOp struct {
defs map[digest.Digest][]byte
metas map[digest.Digest]pb.OpMetadata
sources map[digest.Digest][]*SourceLocation
platforms map[digest.Digest]*specs.Platform
platforms map[digest.Digest]*ocispecs.Platform
dgst digest.Digest
index pb.OutputIndex
inputCache map[digest.Digest][]*DefinitionOp
@ -31,7 +31,7 @@ type DefinitionOp struct {
func NewDefinitionOp(def *pb.Definition) (*DefinitionOp, error) {
ops := make(map[digest.Digest]*pb.Op)
defs := make(map[digest.Digest][]byte)
platforms := make(map[digest.Digest]*specs.Platform)
platforms := make(map[digest.Digest]*ocispecs.Platform)
var dgst digest.Digest
for _, dt := range def.Def {
@ -43,7 +43,7 @@ func NewDefinitionOp(def *pb.Definition) (*DefinitionOp, error) {
ops[dgst] = &op
defs[dgst] = dt
var platform *specs.Platform
var platform *ocispecs.Platform
if op.Platform != nil {
spec := op.Platform.Spec()
platform = &spec

View File

@ -9,7 +9,7 @@ import (
"github.com/containerd/containerd/platforms"
"github.com/google/shlex"
"github.com/moby/buildkit/solver/pb"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)
type contextKeyT string
@ -182,20 +182,20 @@ func shlexf(str string, replace bool, v ...interface{}) StateOption {
}
}
func platform(p specs.Platform) StateOption {
func platform(p ocispecs.Platform) StateOption {
return func(s State) State {
return s.WithValue(keyPlatform, platforms.Normalize(p))
}
}
func getPlatform(s State) func(context.Context, *Constraints) (*specs.Platform, error) {
return func(ctx context.Context, c *Constraints) (*specs.Platform, error) {
func getPlatform(s State) func(context.Context, *Constraints) (*ocispecs.Platform, error) {
return func(ctx context.Context, c *Constraints) (*ocispecs.Platform, error) {
v, err := s.getValue(keyPlatform)(ctx, c)
if err != nil {
return nil, err
}
if v != nil {
p := v.(specs.Platform)
p := v.(ocispecs.Platform)
return &p, nil
}
return nil, nil

View File

@ -4,7 +4,7 @@ import (
"context"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)
// WithMetaResolver adds a metadata resolver to an image
@ -29,7 +29,7 @@ type ImageMetaResolver interface {
}
type ResolveImageConfigOpt struct {
Platform *specs.Platform
Platform *ocispecs.Platform
ResolveMode string
LogName string
}

View File

@ -4,7 +4,7 @@ import (
"context"
"github.com/moby/buildkit/solver/pb"
"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
)
type SourceMap struct {

View File

@ -12,7 +12,7 @@ import (
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/apicaps"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)
type StateOption func(State) State
@ -48,7 +48,7 @@ type State struct {
func (s State) ensurePlatform() State {
if o, ok := s.out.(interface {
Platform() *specs.Platform
Platform() *ocispecs.Platform
}); ok {
if p := o.Platform(); p != nil {
s = platform(*p)(s)
@ -351,11 +351,11 @@ func (s State) GetHostname(ctx context.Context, co ...ConstraintsOpt) (string, e
return getHostname(s)(ctx, c)
}
func (s State) Platform(p specs.Platform) State {
func (s State) Platform(p ocispecs.Platform) State {
return platform(p)(s)
}
func (s State) GetPlatform(ctx context.Context, co ...ConstraintsOpt) (*specs.Platform, error) {
func (s State) GetPlatform(ctx context.Context, co ...ConstraintsOpt) (*ocispecs.Platform, error) {
c := &Constraints{}
for _, f := range co {
f.SetConstraintsOption(c)
@ -403,7 +403,7 @@ type output struct {
vertex Vertex
getIndex func() (pb.OutputIndex, error)
err error
platform *specs.Platform
platform *ocispecs.Platform
}
func (o *output) ToInput(ctx context.Context, c *Constraints) (*pb.Input, error) {
@ -429,7 +429,7 @@ func (o *output) Vertex(context.Context, *Constraints) Vertex {
return o.vertex
}
func (o *output) Platform() *specs.Platform {
func (o *output) Platform() *ocispecs.Platform {
return o.platform
}
@ -560,7 +560,7 @@ func (cw *constraintsWrapper) applyConstraints(f func(c *Constraints)) {
}
type Constraints struct {
Platform *specs.Platform
Platform *ocispecs.Platform
WorkerConstraints []string
Metadata pb.OpMetadata
LocalUniqueID string
@ -568,7 +568,7 @@ type Constraints struct {
SourceLocations []*SourceLocation
}
func Platform(p specs.Platform) ConstraintsOpt {
func Platform(p ocispecs.Platform) ConstraintsOpt {
return constraintsOptFunc(func(c *Constraints) {
c.Platform = &p
})
@ -581,15 +581,15 @@ func LocalUniqueID(v string) ConstraintsOpt {
}
var (
LinuxAmd64 = Platform(specs.Platform{OS: "linux", Architecture: "amd64"})
LinuxArmhf = Platform(specs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"})
LinuxAmd64 = Platform(ocispecs.Platform{OS: "linux", Architecture: "amd64"})
LinuxArmhf = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"})
LinuxArm = LinuxArmhf
LinuxArmel = Platform(specs.Platform{OS: "linux", Architecture: "arm", Variant: "v6"})
LinuxArm64 = Platform(specs.Platform{OS: "linux", Architecture: "arm64"})
LinuxS390x = Platform(specs.Platform{OS: "linux", Architecture: "s390x"})
LinuxPpc64le = Platform(specs.Platform{OS: "linux", Architecture: "ppc64le"})
Darwin = Platform(specs.Platform{OS: "darwin", Architecture: "amd64"})
Windows = Platform(specs.Platform{OS: "windows", Architecture: "amd64"})
LinuxArmel = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v6"})
LinuxArm64 = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm64"})
LinuxS390x = Platform(ocispecs.Platform{OS: "linux", Architecture: "s390x"})
LinuxPpc64le = Platform(ocispecs.Platform{OS: "linux", Architecture: "ppc64le"})
Darwin = Platform(ocispecs.Platform{OS: "darwin", Architecture: "amd64"})
Windows = Platform(ocispecs.Platform{OS: "windows", Architecture: "amd64"})
)
func Require(filters ...string) ConstraintsOpt {

View File

@ -6,7 +6,7 @@ import (
"os"
"github.com/gofrs/flock"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@ -17,9 +17,9 @@ const (
// PutDescToIndex puts desc to index with tag.
// Existing manifests with the same tag will be removed from the index.
func PutDescToIndex(index *v1.Index, desc v1.Descriptor, tag string) error {
func PutDescToIndex(index *ocispecs.Index, desc ocispecs.Descriptor, tag string) error {
if index == nil {
index = &v1.Index{}
index = &ocispecs.Index{}
}
if index.SchemaVersion == 0 {
index.SchemaVersion = 2
@ -28,11 +28,11 @@ func PutDescToIndex(index *v1.Index, desc v1.Descriptor, tag string) error {
if desc.Annotations == nil {
desc.Annotations = make(map[string]string)
}
desc.Annotations[v1.AnnotationRefName] = tag
desc.Annotations[ocispecs.AnnotationRefName] = tag
// remove existing manifests with the same tag
var manifests []v1.Descriptor
var manifests []ocispecs.Descriptor
for _, m := range index.Manifests {
if m.Annotations[v1.AnnotationRefName] != tag {
if m.Annotations[ocispecs.AnnotationRefName] != tag {
manifests = append(manifests, m)
}
}
@ -42,7 +42,7 @@ func PutDescToIndex(index *v1.Index, desc v1.Descriptor, tag string) error {
return nil
}
func PutDescToIndexJSONFileLocked(indexJSONPath string, desc v1.Descriptor, tag string) error {
func PutDescToIndexJSONFileLocked(indexJSONPath string, desc ocispecs.Descriptor, tag string) error {
lockPath := indexJSONPath + IndexJSONLockFileSuffix
lock := flock.New(lockPath)
locked, err := lock.TryLock()
@ -61,7 +61,7 @@ func PutDescToIndexJSONFileLocked(indexJSONPath string, desc v1.Descriptor, tag
return errors.Wrapf(err, "could not open %s", indexJSONPath)
}
defer f.Close()
var idx v1.Index
var idx ocispecs.Index
b, err := ioutil.ReadAll(f)
if err != nil {
return errors.Wrapf(err, "could not read %s", indexJSONPath)
@ -87,7 +87,7 @@ func PutDescToIndexJSONFileLocked(indexJSONPath string, desc v1.Descriptor, tag
return nil
}
func ReadIndexJSONFileLocked(indexJSONPath string) (*v1.Index, error) {
func ReadIndexJSONFileLocked(indexJSONPath string) (*ocispecs.Index, error) {
lockPath := indexJSONPath + IndexJSONLockFileSuffix
lock := flock.New(lockPath)
locked, err := lock.TryRLock()
@ -105,7 +105,7 @@ func ReadIndexJSONFileLocked(indexJSONPath string) (*v1.Index, error) {
if err != nil {
return nil, errors.Wrapf(err, "could not read %s", indexJSONPath)
}
var idx v1.Index
var idx ocispecs.Index
if err := json.Unmarshal(b, &idx); err != nil {
return nil, errors.Wrapf(err, "could not unmarshal %s (%q)", indexJSONPath, string(b))
}

View File

@ -20,10 +20,10 @@ import (
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/session/grpchijack"
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/entitlements"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
fstypes "github.com/tonistiigi/fsutil/types"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sync/errgroup"
@ -109,7 +109,7 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
}
}
cacheOpt, err := parseCacheOptions(opt)
cacheOpt, err := parseCacheOptions(ctx, opt)
if err != nil {
return nil, err
}
@ -181,7 +181,7 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
<-time.After(3 * time.Second)
cancelStatus()
}()
logrus.Debugf("stopping session")
bklog.G(ctx).Debugf("stopping session")
s.Close()
}()
var pbd *pb.Definition
@ -300,7 +300,7 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
// Update index.json of exported cache content store
// FIXME(AkihiroSuda): dedupe const definition of cache/remotecache.ExporterResponseManifestDesc = "cache.manifest"
if manifestDescJSON := res.ExporterResponse["cache.manifest"]; manifestDescJSON != "" {
var manifestDesc ocispec.Descriptor
var manifestDesc ocispecs.Descriptor
if err = json.Unmarshal([]byte(manifestDescJSON), &manifestDesc); err != nil {
return nil, err
}
@ -341,13 +341,13 @@ func prepareSyncedDirs(def *llb.Definition, localDirs map[string]string) ([]file
return nil, errors.Wrap(err, "failed to parse llb proto op")
}
if src := op.GetSource(); src != nil {
if strings.HasPrefix(src.Identifier, "local://") { // TODO: just make a type property
if strings.HasPrefix(src.Identifier, "local://") {
name := strings.TrimPrefix(src.Identifier, "local://")
d, ok := localDirs[name]
if !ok {
return nil, errors.Errorf("local directory %s not enabled", name)
}
dirs = append(dirs, filesync.SyncedDir{Name: name, Dir: d, Map: resetUIDAndGID}) // TODO: excludes
dirs = append(dirs, filesync.SyncedDir{Name: name, Dir: d, Map: resetUIDAndGID})
}
}
}
@ -370,7 +370,7 @@ type cacheOptions struct {
frontendAttrs map[string]string
}
func parseCacheOptions(opt SolveOpt) (*cacheOptions, error) {
func parseCacheOptions(ctx context.Context, opt SolveOpt) (*cacheOptions, error) {
var (
cacheExports []*controlapi.CacheOptionsEntry
cacheImports []*controlapi.CacheOptionsEntry
@ -423,18 +423,18 @@ func parseCacheOptions(opt SolveOpt) (*cacheOptions, error) {
}
cs, err := contentlocal.NewStore(csDir)
if err != nil {
logrus.Warning("local cache import at " + csDir + " not found due to err: " + err.Error())
bklog.G(ctx).Warning("local cache import at " + csDir + " not found due to err: " + err.Error())
continue
}
// if digest is not specified, load from "latest" tag
if attrs["digest"] == "" {
idx, err := ociindex.ReadIndexJSONFileLocked(filepath.Join(csDir, "index.json"))
if err != nil {
logrus.Warning("local cache import at " + csDir + " not found due to err: " + err.Error())
bklog.G(ctx).Warning("local cache import at " + csDir + " not found due to err: " + err.Error())
continue
}
for _, m := range idx.Manifests {
if (m.Annotations[ocispec.AnnotationRefName] == "latest" && attrs["tag"] == "") || (attrs["tag"] != "" && m.Annotations[ocispec.AnnotationRefName] == attrs["tag"]) {
if (m.Annotations[ocispecs.AnnotationRefName] == "latest" && attrs["tag"] == "") || (attrs["tag"] != "" && m.Annotations[ocispecs.AnnotationRefName] == attrs["tag"]) {
attrs["digest"] = string(m.Digest)
break
}

View File

@ -7,7 +7,7 @@ import (
controlapi "github.com/moby/buildkit/api/services/control"
apitypes "github.com/moby/buildkit/api/types"
"github.com/moby/buildkit/solver/pb"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@ -15,7 +15,7 @@ import (
type WorkerInfo struct {
ID string
Labels map[string]string
Platforms []specs.Platform
Platforms []ocispecs.Platform
GCPolicy []PruneInfo
}