mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
18
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
18
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
@ -29,7 +29,8 @@ import (
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
conn *grpc.ClientConn
|
||||
conn *grpc.ClientConn
|
||||
sessionDialer func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error)
|
||||
}
|
||||
|
||||
type ClientOpt interface{}
|
||||
@ -49,6 +50,7 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
var customTracer bool // allows manually setting disabling tracing even if tracer in context
|
||||
var tracerProvider trace.TracerProvider
|
||||
var tracerDelegate TracerDelegate
|
||||
var sessionDialer func(context.Context, string, map[string][]string) (net.Conn, error)
|
||||
|
||||
for _, o := range opts {
|
||||
if _, ok := o.(*withFailFast); ok {
|
||||
@ -73,6 +75,9 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
if wt, ok := o.(*withTracerDelegate); ok {
|
||||
tracerDelegate = wt
|
||||
}
|
||||
if sd, ok := o.(*withSessionDialer); ok {
|
||||
sessionDialer = sd.dialer
|
||||
}
|
||||
}
|
||||
|
||||
if !customTracer {
|
||||
@ -131,7 +136,8 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
}
|
||||
|
||||
c := &Client{
|
||||
conn: conn,
|
||||
conn: conn,
|
||||
sessionDialer: sessionDialer,
|
||||
}
|
||||
|
||||
if tracerDelegate != nil {
|
||||
@ -244,6 +250,14 @@ type withTracerDelegate struct {
|
||||
TracerDelegate
|
||||
}
|
||||
|
||||
func WithSessionDialer(dialer func(context.Context, string, map[string][]string) (net.Conn, error)) ClientOpt {
|
||||
return &withSessionDialer{dialer}
|
||||
}
|
||||
|
||||
type withSessionDialer struct {
|
||||
dialer func(context.Context, string, map[string][]string) (net.Conn, error)
|
||||
}
|
||||
|
||||
func resolveDialer(address string) (func(context.Context, string) (net.Conn, error), error) {
|
||||
ch, err := connhelper.GetConnectionHelper(address)
|
||||
if err != nil {
|
||||
|
48
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
48
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
@ -43,6 +43,7 @@ type mount struct {
|
||||
selector string
|
||||
cacheID string
|
||||
tmpfs bool
|
||||
tmpfsOpt TmpfsInfo
|
||||
cacheSharing CacheMountSharingMode
|
||||
noOutput bool
|
||||
}
|
||||
@ -205,14 +206,6 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
meta.ExtraHosts = hosts
|
||||
}
|
||||
|
||||
shmSize, err := getShmSize(e.base)(ctx, c)
|
||||
if err != nil {
|
||||
return "", nil, nil, nil, err
|
||||
}
|
||||
if shmSize != nil {
|
||||
meta.ShmSize = *shmSize
|
||||
}
|
||||
|
||||
ulimits, err := getUlimit(e.base)(ctx, c)
|
||||
if err != nil {
|
||||
return "", nil, nil, nil, err
|
||||
@ -275,6 +268,9 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
addCap(&e.constraints, pb.CapExecMountCacheSharing)
|
||||
} else if m.tmpfs {
|
||||
addCap(&e.constraints, pb.CapExecMountTmpfs)
|
||||
if m.tmpfsOpt.Size > 0 {
|
||||
addCap(&e.constraints, pb.CapExecMountTmpfsSize)
|
||||
}
|
||||
} else if m.source != nil {
|
||||
addCap(&e.constraints, pb.CapExecMountBind)
|
||||
}
|
||||
@ -359,6 +355,9 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
}
|
||||
if m.tmpfs {
|
||||
pm.MountType = pb.MountType_TMPFS
|
||||
pm.TmpfsOpt = &pb.TmpfsOpt{
|
||||
Size_: m.tmpfsOpt.Size,
|
||||
}
|
||||
}
|
||||
peo.Mounts = append(peo.Mounts, pm)
|
||||
}
|
||||
@ -479,12 +478,37 @@ func AsPersistentCacheDir(id string, sharing CacheMountSharingMode) MountOption
|
||||
}
|
||||
}
|
||||
|
||||
func Tmpfs() MountOption {
|
||||
func Tmpfs(opts ...TmpfsOption) MountOption {
|
||||
return func(m *mount) {
|
||||
t := &TmpfsInfo{}
|
||||
for _, opt := range opts {
|
||||
opt.SetTmpfsOption(t)
|
||||
}
|
||||
m.tmpfs = true
|
||||
m.tmpfsOpt = *t
|
||||
}
|
||||
}
|
||||
|
||||
type TmpfsOption interface {
|
||||
SetTmpfsOption(*TmpfsInfo)
|
||||
}
|
||||
|
||||
type tmpfsOptionFunc func(*TmpfsInfo)
|
||||
|
||||
func (fn tmpfsOptionFunc) SetTmpfsOption(ti *TmpfsInfo) {
|
||||
fn(ti)
|
||||
}
|
||||
|
||||
func TmpfsSize(b int64) TmpfsOption {
|
||||
return tmpfsOptionFunc(func(ti *TmpfsInfo) {
|
||||
ti.Size = b
|
||||
})
|
||||
}
|
||||
|
||||
type TmpfsInfo struct {
|
||||
Size int64
|
||||
}
|
||||
|
||||
type RunOption interface {
|
||||
SetRunOption(es *ExecInfo)
|
||||
}
|
||||
@ -524,12 +548,6 @@ func AddExtraHost(host string, ip net.IP) RunOption {
|
||||
})
|
||||
}
|
||||
|
||||
func WithShmSize(kb int64) RunOption {
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
ei.State = ei.State.WithShmSize(kb)
|
||||
})
|
||||
}
|
||||
|
||||
func AddUlimit(name UlimitName, soft int64, hard int64) RunOption {
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
ei.State = ei.State.AddUlimit(name, soft, hard)
|
||||
|
21
vendor/github.com/moby/buildkit/client/llb/meta.go
generated
vendored
21
vendor/github.com/moby/buildkit/client/llb/meta.go
generated
vendored
@ -20,7 +20,6 @@ var (
|
||||
keyEnv = contextKeyT("llb.exec.env")
|
||||
keyExtraHost = contextKeyT("llb.exec.extrahost")
|
||||
keyHostname = contextKeyT("llb.exec.hostname")
|
||||
keyShmSize = contextKeyT("llb.exec.shmsize")
|
||||
keyUlimit = contextKeyT("llb.exec.ulimit")
|
||||
keyUser = contextKeyT("llb.exec.user")
|
||||
|
||||
@ -235,26 +234,6 @@ type HostIP struct {
|
||||
IP net.IP
|
||||
}
|
||||
|
||||
func shmSize(kb int64) StateOption {
|
||||
return func(s State) State {
|
||||
return s.WithValue(keyShmSize, kb)
|
||||
}
|
||||
}
|
||||
|
||||
func getShmSize(s State) func(context.Context, *Constraints) (*int64, error) {
|
||||
return func(ctx context.Context, c *Constraints) (*int64, error) {
|
||||
v, err := s.getValue(keyShmSize)(ctx, c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if v != nil {
|
||||
kb := v.(int64)
|
||||
return &kb, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func ulimit(name UlimitName, soft int64, hard int64) StateOption {
|
||||
return func(s State) State {
|
||||
return s.withValue(keyUlimit, func(ctx context.Context, c *Constraints) (interface{}, error) {
|
||||
|
4
vendor/github.com/moby/buildkit/client/llb/state.go
generated
vendored
4
vendor/github.com/moby/buildkit/client/llb/state.go
generated
vendored
@ -397,10 +397,6 @@ func (s State) AddExtraHost(host string, ip net.IP) State {
|
||||
return extraHost(host, ip)(s)
|
||||
}
|
||||
|
||||
func (s State) WithShmSize(kb int64) State {
|
||||
return shmSize(kb)(s)
|
||||
}
|
||||
|
||||
func (s State) AddUlimit(name UlimitName, soft int64, hard int64) State {
|
||||
return ulimit(name, soft, hard)(s)
|
||||
}
|
||||
|
6
vendor/github.com/moby/buildkit/client/solve.go
generated
vendored
6
vendor/github.com/moby/buildkit/client/solve.go
generated
vendored
@ -162,7 +162,11 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
|
||||
}
|
||||
|
||||
eg.Go(func() error {
|
||||
return s.Run(statusContext, grpchijack.Dialer(c.controlClient()))
|
||||
sd := c.sessionDialer
|
||||
if sd == nil {
|
||||
sd = grpchijack.Dialer(c.controlClient())
|
||||
}
|
||||
return s.Run(statusContext, sd)
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user