mirror of
https://github.com/moby/buildkit.git
synced 2026-08-04 14:50:21 +00:00
Remove the need for an exported Executor field
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
@@ -211,8 +211,16 @@ func docopy(ctx context.Context, src, dest string, action pb.FileActionCopy, u *
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewFileOpBackend returns a new file operation backend. The executor is currently only used for Windows,
|
||||
// and it is used to construct the readUserFn field set in the returned Backend.
|
||||
func NewFileOpBackend(exec executor.Executor) *Backend {
|
||||
return &Backend{
|
||||
readUserFn: getReadUserFn(exec),
|
||||
}
|
||||
}
|
||||
|
||||
type Backend struct {
|
||||
Executor executor.Executor
|
||||
readUserFn func(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error)
|
||||
}
|
||||
|
||||
func (fb *Backend) Mkdir(ctx context.Context, m, user, group fileoptypes.Mount, action pb.FileActionMkDir) error {
|
||||
@@ -228,7 +236,8 @@ func (fb *Backend) Mkdir(ctx context.Context, m, user, group fileoptypes.Mount,
|
||||
}
|
||||
defer lm.Unmount()
|
||||
|
||||
u, err := readUser(action.Owner, user, group, fb.Executor)
|
||||
// u, err := readUser(action.Owner, user, group, fb.Executor)
|
||||
u, err := fb.readUserFn(action.Owner, user, group)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -249,7 +258,7 @@ func (fb *Backend) Mkfile(ctx context.Context, m, user, group fileoptypes.Mount,
|
||||
}
|
||||
defer lm.Unmount()
|
||||
|
||||
u, err := readUser(action.Owner, user, group, fb.Executor)
|
||||
u, err := fb.readUserFn(action.Owner, user, group)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -297,7 +306,7 @@ func (fb *Backend) Copy(ctx context.Context, m1, m2, user, group fileoptypes.Mou
|
||||
}
|
||||
defer lm2.Unmount()
|
||||
|
||||
u, err := readUser(action.Owner, user, group, fb.Executor)
|
||||
u, err := fb.readUserFn(action.Owner, user, group)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ import (
|
||||
copy "github.com/tonistiigi/fsutil/copy"
|
||||
)
|
||||
|
||||
func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount, exec executor.Executor) (*copy.User, error) {
|
||||
func getReadUserFn(exec executor.Executor) func(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
|
||||
return readUser
|
||||
}
|
||||
|
||||
func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
|
||||
if chopt == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -11,7 +11,11 @@ import (
|
||||
copy "github.com/tonistiigi/fsutil/copy"
|
||||
)
|
||||
|
||||
func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount, exec executor.Executor) (*copy.User, error) {
|
||||
func getReadUserFn(exec executor.Executor) func(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
|
||||
return readUser
|
||||
}
|
||||
|
||||
func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
|
||||
if chopt == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@ import (
|
||||
copy "github.com/tonistiigi/fsutil/copy"
|
||||
)
|
||||
|
||||
func getReadUserFn(exec executor.Executor) func(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
|
||||
return func(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
|
||||
return readUser(chopt, mu, mg, exec)
|
||||
}
|
||||
}
|
||||
|
||||
func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount, exec executor.Executor) (*copy.User, error) {
|
||||
if chopt == nil {
|
||||
return nil, nil
|
||||
|
||||
@@ -167,7 +167,9 @@ func (f *fileOp) Exec(ctx context.Context, g session.Group, inputs []solver.Resu
|
||||
inpRefs = append(inpRefs, workerRef.ImmutableRef)
|
||||
}
|
||||
|
||||
fs := NewFileOpSolver(f.w, &file.Backend{Executor: f.w.Executor()}, f.refManager)
|
||||
backend := file.NewFileOpBackend(f.w.Executor())
|
||||
|
||||
fs := NewFileOpSolver(f.w, backend, f.refManager)
|
||||
outs, err := fs.Solve(ctx, inpRefs, f.op.Actions, g)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user