vendor: update buildkit

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-10-19 21:03:09 +02:00
parent 868610e0e9
commit 22500c9929
11 changed files with 459 additions and 255 deletions

View File

@ -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)