vendor: update buildkit to f449174742bf
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
+24
@@ -1,5 +1,11 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
ExporterImage = "image"
|
||||
ExporterLocal = "local"
|
||||
@@ -7,3 +13,21 @@ const (
|
||||
ExporterOCI = "oci"
|
||||
ExporterDocker = "docker"
|
||||
)
|
||||
|
||||
type LocalExporterMode string
|
||||
|
||||
const (
|
||||
LocalExporterModeCopy LocalExporterMode = "copy"
|
||||
LocalExporterModeDelete LocalExporterMode = "delete"
|
||||
)
|
||||
|
||||
func ParseLocalExporterMode(v string) (LocalExporterMode, error) {
|
||||
switch strings.ToLower(strings.TrimSpace(v)) {
|
||||
case "", string(LocalExporterModeCopy):
|
||||
return LocalExporterModeCopy, nil
|
||||
case string(LocalExporterModeDelete):
|
||||
return LocalExporterModeDelete, nil
|
||||
default:
|
||||
return "", errors.Errorf("invalid local exporter mode %q", v)
|
||||
}
|
||||
}
|
||||
|
||||
+16
-1
@@ -189,7 +189,22 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
|
||||
if ex.OutputDir == "" {
|
||||
return nil, errors.Errorf("output directory is required for %s exporter", ex.Type)
|
||||
}
|
||||
syncTargets = append(syncTargets, filesync.WithFSSyncDir(exID, ex.OutputDir))
|
||||
if ex.Type == ExporterLocal {
|
||||
mode := LocalExporterModeCopy
|
||||
if ex.Attrs != nil {
|
||||
mode, err = ParseLocalExporterMode(ex.Attrs["mode"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if mode == LocalExporterModeDelete {
|
||||
syncTargets = append(syncTargets, filesync.WithFSSyncDirDelete(exID, ex.OutputDir))
|
||||
} else {
|
||||
syncTargets = append(syncTargets, filesync.WithFSSyncDir(exID, ex.OutputDir))
|
||||
}
|
||||
} else {
|
||||
syncTargets = append(syncTargets, filesync.WithFSSyncDir(exID, ex.OutputDir))
|
||||
}
|
||||
}
|
||||
if supportStore {
|
||||
store := ex.OutputStore
|
||||
|
||||
+20
-4
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/moby/buildkit/util/bklog"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tonistiigi/fsutil"
|
||||
fstypes "github.com/tonistiigi/fsutil/types"
|
||||
@@ -111,11 +110,12 @@ func recvDiffCopy(ds grpc.ClientStream, dest string, cu CacheUpdater, progress p
|
||||
}))
|
||||
}
|
||||
|
||||
func syncTargetDiffCopy(ds grpc.ServerStream, dest string) error {
|
||||
func syncTargetDiffCopy(ds grpc.ServerStream, dest string, deleteMode bool) error {
|
||||
if err := os.MkdirAll(dest, 0700); err != nil {
|
||||
return errors.Wrapf(err, "failed to create synctarget dest dir %s", dest)
|
||||
}
|
||||
return errors.WithStack(fsutil.Receive(ds.Context(), ds, dest, fsutil.ReceiveOpt{
|
||||
|
||||
opt := fsutil.ReceiveOpt{
|
||||
Merge: true,
|
||||
Filter: func() func(string, *fstypes.Stat) bool {
|
||||
uid := os.Getuid()
|
||||
@@ -126,7 +126,23 @@ func syncTargetDiffCopy(ds grpc.ServerStream, dest string) error {
|
||||
return true
|
||||
}
|
||||
}(),
|
||||
}))
|
||||
}
|
||||
|
||||
osRoot, err := os.OpenRoot(dest)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to open synctarget dest root %s", dest)
|
||||
}
|
||||
root := fsutil.NewRoot(osRoot)
|
||||
defer root.Close()
|
||||
|
||||
if deleteMode {
|
||||
opt.Merge = false
|
||||
// Request every source file so delete mode mirrors file contents without
|
||||
// relying on fsutil's path-based content comparison.
|
||||
opt.Differ = fsutil.DiffNone
|
||||
}
|
||||
|
||||
return errors.WithStack(fsutil.ReceiveRoot(ds.Context(), ds, root, opt))
|
||||
}
|
||||
|
||||
func writeTargetFile(ds grpc.ServerStream, wc io.WriteCloser) error {
|
||||
|
||||
+22
-8
@@ -253,9 +253,10 @@ type FSSyncTarget interface {
|
||||
}
|
||||
|
||||
type fsSyncTarget struct {
|
||||
id int
|
||||
outdir string
|
||||
f FileOutputFunc
|
||||
id int
|
||||
outdir string
|
||||
deleteMode bool
|
||||
f FileOutputFunc
|
||||
}
|
||||
|
||||
func (target *fsSyncTarget) target() *fsSyncTarget {
|
||||
@@ -276,10 +277,23 @@ func WithFSSyncDir(id int, outdir string) FSSyncTarget {
|
||||
}
|
||||
}
|
||||
|
||||
func WithFSSyncDirDelete(id int, outdir string) FSSyncTarget {
|
||||
return &fsSyncTarget{
|
||||
id: id,
|
||||
outdir: outdir,
|
||||
deleteMode: true,
|
||||
}
|
||||
}
|
||||
|
||||
type fsSyncDirTarget struct {
|
||||
outdir string
|
||||
deleteMode bool
|
||||
}
|
||||
|
||||
func NewFSSyncTarget(targets ...FSSyncTarget) *SyncTarget {
|
||||
st := &SyncTarget{
|
||||
fs: make(map[int]FileOutputFunc),
|
||||
outdirs: make(map[int]string),
|
||||
outdirs: make(map[int]fsSyncDirTarget),
|
||||
}
|
||||
st.Add(targets...)
|
||||
return st
|
||||
@@ -287,7 +301,7 @@ func NewFSSyncTarget(targets ...FSSyncTarget) *SyncTarget {
|
||||
|
||||
type SyncTarget struct {
|
||||
fs map[int]FileOutputFunc
|
||||
outdirs map[int]string
|
||||
outdirs map[int]fsSyncDirTarget
|
||||
}
|
||||
|
||||
var _ session.Attachable = &SyncTarget{}
|
||||
@@ -299,7 +313,7 @@ func (sp *SyncTarget) Add(targets ...FSSyncTarget) {
|
||||
sp.fs[t.id] = t.f
|
||||
}
|
||||
if t.outdir != "" {
|
||||
sp.outdirs[t.id] = t.outdir
|
||||
sp.outdirs[t.id] = fsSyncDirTarget{outdir: t.outdir, deleteMode: t.deleteMode}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,8 +340,8 @@ func (sp *SyncTarget) chooser(ctx context.Context) int {
|
||||
|
||||
func (sp *SyncTarget) DiffCopy(stream FileSend_DiffCopyServer) (err error) {
|
||||
id := sp.chooser(stream.Context())
|
||||
if outdir, ok := sp.outdirs[id]; ok {
|
||||
return syncTargetDiffCopy(stream, outdir)
|
||||
if target, ok := sp.outdirs[id]; ok {
|
||||
return syncTargetDiffCopy(stream, target.outdir, target.deleteMode)
|
||||
}
|
||||
f, ok := sp.fs[id]
|
||||
if !ok {
|
||||
|
||||
+2
-6
@@ -30,7 +30,6 @@ const (
|
||||
NetMode_UNSET NetMode = 0 // sandbox
|
||||
NetMode_HOST NetMode = 1
|
||||
NetMode_NONE NetMode = 2
|
||||
NetMode_PROXY NetMode = 3
|
||||
)
|
||||
|
||||
// Enum value maps for NetMode.
|
||||
@@ -39,13 +38,11 @@ var (
|
||||
0: "UNSET",
|
||||
1: "HOST",
|
||||
2: "NONE",
|
||||
3: "PROXY",
|
||||
}
|
||||
NetMode_value = map[string]int32{
|
||||
"UNSET": 0,
|
||||
"HOST": 1,
|
||||
"NONE": 2,
|
||||
"PROXY": 3,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3845,12 +3842,11 @@ const file_github_com_moby_buildkit_solver_pb_ops_proto_rawDesc = "" +
|
||||
"\x05upper\x18\x02 \x01(\v2\x12.pb.UpperDiffInputR\x05upper\"9\n" +
|
||||
"\rPassthroughOp\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x18\n" +
|
||||
"\aoutputs\x18\x02 \x03(\x03R\aoutputs*3\n" +
|
||||
"\aoutputs\x18\x02 \x03(\x03R\aoutputs*(\n" +
|
||||
"\aNetMode\x12\t\n" +
|
||||
"\x05UNSET\x10\x00\x12\b\n" +
|
||||
"\x04HOST\x10\x01\x12\b\n" +
|
||||
"\x04NONE\x10\x02\x12\t\n" +
|
||||
"\x05PROXY\x10\x03*)\n" +
|
||||
"\x04NONE\x10\x02*)\n" +
|
||||
"\fSecurityMode\x12\v\n" +
|
||||
"\aSANDBOX\x10\x00\x12\f\n" +
|
||||
"\bINSECURE\x10\x01*@\n" +
|
||||
|
||||
-1
@@ -83,7 +83,6 @@ enum NetMode {
|
||||
UNSET = 0; // sandbox
|
||||
HOST = 1;
|
||||
NONE = 2;
|
||||
PROXY = 3;
|
||||
}
|
||||
|
||||
enum SecurityMode {
|
||||
|
||||
Reference in New Issue
Block a user