mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to master@8b7bcb900d3c
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
45
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
45
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
@ -11,7 +11,6 @@ import (
|
||||
|
||||
contentapi "github.com/containerd/containerd/api/services/content/v1"
|
||||
"github.com/containerd/containerd/defaults"
|
||||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||
controlapi "github.com/moby/buildkit/api/services/control"
|
||||
"github.com/moby/buildkit/client/connhelper"
|
||||
"github.com/moby/buildkit/session"
|
||||
@ -35,7 +34,9 @@ type Client struct {
|
||||
sessionDialer func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error)
|
||||
}
|
||||
|
||||
type ClientOpt interface{}
|
||||
type ClientOpt interface {
|
||||
isClientOpt()
|
||||
}
|
||||
|
||||
// New returns a new buildkit client. Address can be empty for the system-default address.
|
||||
func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error) {
|
||||
@ -54,6 +55,7 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
var tracerProvider trace.TracerProvider
|
||||
var tracerDelegate TracerDelegate
|
||||
var sessionDialer func(context.Context, string, map[string][]string) (net.Conn, error)
|
||||
var customDialOptions []grpc.DialOption
|
||||
|
||||
for _, o := range opts {
|
||||
if _, ok := o.(*withFailFast); ok {
|
||||
@ -82,6 +84,9 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
if sd, ok := o.(*withSessionDialer); ok {
|
||||
sessionDialer = sd.dialer
|
||||
}
|
||||
if opt, ok := o.(*withGRPCDialOption); ok {
|
||||
customDialOptions = append(customDialOptions, opt.opt)
|
||||
}
|
||||
}
|
||||
|
||||
if !customTracer {
|
||||
@ -131,17 +136,9 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
unary = append(unary, grpcerrors.UnaryClientInterceptor)
|
||||
stream = append(stream, grpcerrors.StreamClientInterceptor)
|
||||
|
||||
if len(unary) == 1 {
|
||||
gopts = append(gopts, grpc.WithUnaryInterceptor(unary[0]))
|
||||
} else if len(unary) > 1 {
|
||||
gopts = append(gopts, grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient(unary...)))
|
||||
}
|
||||
|
||||
if len(stream) == 1 {
|
||||
gopts = append(gopts, grpc.WithStreamInterceptor(stream[0]))
|
||||
} else if len(stream) > 1 {
|
||||
gopts = append(gopts, grpc.WithStreamInterceptor(grpc_middleware.ChainStreamClient(stream...)))
|
||||
}
|
||||
gopts = append(gopts, grpc.WithChainUnaryInterceptor(unary...))
|
||||
gopts = append(gopts, grpc.WithChainStreamInterceptor(stream...))
|
||||
gopts = append(gopts, customDialOptions...)
|
||||
|
||||
conn, err := grpc.DialContext(ctx, address, gopts...)
|
||||
if err != nil {
|
||||
@ -187,6 +184,8 @@ func (c *Client) Close() error {
|
||||
|
||||
type withFailFast struct{}
|
||||
|
||||
func (*withFailFast) isClientOpt() {}
|
||||
|
||||
func WithFailFast() ClientOpt {
|
||||
return &withFailFast{}
|
||||
}
|
||||
@ -195,6 +194,8 @@ type withDialer struct {
|
||||
dialer func(context.Context, string) (net.Conn, error)
|
||||
}
|
||||
|
||||
func (*withDialer) isClientOpt() {}
|
||||
|
||||
func WithContextDialer(df func(context.Context, string) (net.Conn, error)) ClientOpt {
|
||||
return &withDialer{dialer: df}
|
||||
}
|
||||
@ -206,6 +207,8 @@ type withCredentials struct {
|
||||
Key string
|
||||
}
|
||||
|
||||
func (*withCredentials) isClientOpt() {}
|
||||
|
||||
// WithCredentials configures the TLS parameters of the client.
|
||||
// Arguments:
|
||||
// * serverName: specifies the name of the target server
|
||||
@ -252,6 +255,8 @@ type withTracer struct {
|
||||
tp trace.TracerProvider
|
||||
}
|
||||
|
||||
func (w *withTracer) isClientOpt() {}
|
||||
|
||||
type TracerDelegate interface {
|
||||
SetSpanExporter(context.Context, sdktrace.SpanExporter) error
|
||||
}
|
||||
@ -266,6 +271,8 @@ type withTracerDelegate struct {
|
||||
TracerDelegate
|
||||
}
|
||||
|
||||
func (w *withTracerDelegate) isClientOpt() {}
|
||||
|
||||
func WithSessionDialer(dialer func(context.Context, string, map[string][]string) (net.Conn, error)) ClientOpt {
|
||||
return &withSessionDialer{dialer}
|
||||
}
|
||||
@ -274,6 +281,8 @@ type withSessionDialer struct {
|
||||
dialer func(context.Context, string, map[string][]string) (net.Conn, error)
|
||||
}
|
||||
|
||||
func (w *withSessionDialer) isClientOpt() {}
|
||||
|
||||
func resolveDialer(address string) (func(context.Context, string) (net.Conn, error), error) {
|
||||
ch, err := connhelper.GetConnectionHelper(address)
|
||||
if err != nil {
|
||||
@ -294,3 +303,13 @@ func filterInterceptor(intercept grpc.UnaryClientInterceptor) grpc.UnaryClientIn
|
||||
return intercept(ctx, method, req, reply, cc, invoker, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type withGRPCDialOption struct {
|
||||
opt grpc.DialOption
|
||||
}
|
||||
|
||||
func (*withGRPCDialOption) isClientOpt() {}
|
||||
|
||||
func WithGRPCDialOption(opt grpc.DialOption) ClientOpt {
|
||||
return &withGRPCDialOption{opt}
|
||||
}
|
||||
|
3
vendor/github.com/moby/buildkit/client/connhelper/kubepod/kubepod.go
generated
vendored
3
vendor/github.com/moby/buildkit/client/connhelper/kubepod/kubepod.go
generated
vendored
@ -51,9 +51,6 @@ func SpecFromURL(u *url.URL) (*Spec, error) {
|
||||
Pod: u.Hostname(),
|
||||
Container: q.Get("container"),
|
||||
}
|
||||
if sp.Context != "" && !validKubeIdentifier(sp.Context) {
|
||||
return nil, errors.Errorf("unsupported context name: %q", sp.Context)
|
||||
}
|
||||
if sp.Namespace != "" && !validKubeIdentifier(sp.Namespace) {
|
||||
return nil, errors.Errorf("unsupported namespace name: %q", sp.Namespace)
|
||||
}
|
||||
|
5
vendor/github.com/moby/buildkit/client/llb/definition.go
generated
vendored
5
vendor/github.com/moby/buildkit/client/llb/definition.go
generated
vendored
@ -29,6 +29,10 @@ type DefinitionOp struct {
|
||||
|
||||
// NewDefinitionOp returns a new operation from a marshalled definition.
|
||||
func NewDefinitionOp(def *pb.Definition) (*DefinitionOp, error) {
|
||||
if def == nil {
|
||||
return nil, errors.New("invalid nil input definition to definition op")
|
||||
}
|
||||
|
||||
ops := make(map[digest.Digest]*pb.Op)
|
||||
defs := make(map[digest.Digest][]byte)
|
||||
platforms := make(map[digest.Digest]*ocispecs.Platform)
|
||||
@ -205,6 +209,7 @@ func (d *DefinitionOp) Inputs() []Output {
|
||||
dgst: input.Digest,
|
||||
index: input.Index,
|
||||
inputCache: d.inputCache,
|
||||
sources: d.sources,
|
||||
}
|
||||
existingIndexes := d.inputCache[input.Digest]
|
||||
indexDiff := int(input.Index) - len(existingIndexes)
|
||||
|
47
vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
generated
vendored
47
vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
generated
vendored
@ -20,15 +20,18 @@ const (
|
||||
)
|
||||
|
||||
type StoreIndex struct {
|
||||
indexPath string
|
||||
lockPath string
|
||||
indexPath string
|
||||
lockPath string
|
||||
layoutPath string
|
||||
}
|
||||
|
||||
func NewStoreIndex(storePath string) StoreIndex {
|
||||
indexPath := path.Join(storePath, indexFile)
|
||||
layoutPath := path.Join(storePath, ocispecs.ImageLayoutFile)
|
||||
return StoreIndex{
|
||||
indexPath: indexPath,
|
||||
lockPath: indexPath + lockFileSuffix,
|
||||
indexPath: indexPath,
|
||||
lockPath: indexPath + lockFileSuffix,
|
||||
layoutPath: layoutPath,
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +61,7 @@ func (s StoreIndex) Read() (*ocispecs.Index, error) {
|
||||
}
|
||||
|
||||
func (s StoreIndex) Put(tag string, desc ocispecs.Descriptor) error {
|
||||
// lock the store to prevent concurrent access
|
||||
lock := flock.New(s.lockPath)
|
||||
locked, err := lock.TryLock()
|
||||
if err != nil {
|
||||
@ -71,20 +75,33 @@ func (s StoreIndex) Put(tag string, desc ocispecs.Descriptor) error {
|
||||
os.RemoveAll(s.lockPath)
|
||||
}()
|
||||
|
||||
f, err := os.OpenFile(s.indexPath, os.O_RDWR|os.O_CREATE, 0644)
|
||||
// create the oci-layout file
|
||||
layout := ocispecs.ImageLayout{
|
||||
Version: ocispecs.ImageLayoutVersion,
|
||||
}
|
||||
layoutData, err := json.Marshal(layout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(s.layoutPath, layoutData, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// modify the index file
|
||||
idxFile, err := os.OpenFile(s.indexPath, os.O_RDWR|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not open %s", s.indexPath)
|
||||
}
|
||||
defer f.Close()
|
||||
defer idxFile.Close()
|
||||
|
||||
var idx ocispecs.Index
|
||||
b, err := io.ReadAll(f)
|
||||
idxData, err := io.ReadAll(idxFile)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not read %s", s.indexPath)
|
||||
}
|
||||
if len(b) > 0 {
|
||||
if err := json.Unmarshal(b, &idx); err != nil {
|
||||
return errors.Wrapf(err, "could not unmarshal %s (%q)", s.indexPath, string(b))
|
||||
if len(idxData) > 0 {
|
||||
if err := json.Unmarshal(idxData, &idx); err != nil {
|
||||
return errors.Wrapf(err, "could not unmarshal %s (%q)", s.indexPath, string(idxData))
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,15 +109,15 @@ func (s StoreIndex) Put(tag string, desc ocispecs.Descriptor) error {
|
||||
return err
|
||||
}
|
||||
|
||||
b, err = json.Marshal(idx)
|
||||
idxData, err = json.Marshal(idx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = f.WriteAt(b, 0); err != nil {
|
||||
return err
|
||||
if _, err = idxFile.WriteAt(idxData, 0); err != nil {
|
||||
return errors.Wrapf(err, "could not write %s", s.indexPath)
|
||||
}
|
||||
if err = f.Truncate(int64(len(b))); err != nil {
|
||||
return err
|
||||
if err = idxFile.Truncate(int64(len(idxData))); err != nil {
|
||||
return errors.Wrapf(err, "could not truncate %s", s.indexPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
2
vendor/github.com/moby/buildkit/client/solve.go
generated
vendored
2
vendor/github.com/moby/buildkit/client/solve.go
generated
vendored
@ -169,7 +169,7 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
|
||||
}
|
||||
|
||||
if supportFile && supportDir {
|
||||
return nil, errors.Errorf("both file and directory output is not support by %s exporter", ex.Type)
|
||||
return nil, errors.Errorf("both file and directory output is not supported by %s exporter", ex.Type)
|
||||
}
|
||||
if !supportFile && ex.Output != nil {
|
||||
return nil, errors.Errorf("output file writer is not supported by %s exporter", ex.Type)
|
||||
|
Reference in New Issue
Block a user