mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-16 08:27:06 +08:00
vendor: update moby/buildkit
Update modules: go mod edit -require github.com/moby/buildkit@master go mod tidy -compat=1.17 && ./hack/update-vendor Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
30
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
30
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
@ -19,9 +19,29 @@ type WalkOpt struct {
|
||||
// FollowPaths contains symlinks that are resolved into include patterns
|
||||
// before performing the fs walk
|
||||
FollowPaths []string
|
||||
Map FilterFunc
|
||||
Map MapFunc
|
||||
}
|
||||
|
||||
type MapFunc func(string, *types.Stat) MapResult
|
||||
|
||||
// The result of the walk function controls
|
||||
// both how WalkDir continues and whether the path is kept.
|
||||
type MapResult int
|
||||
|
||||
const (
|
||||
// Keep the current path and continue.
|
||||
MapResultKeep MapResult = iota
|
||||
|
||||
// Exclude the current path and continue.
|
||||
MapResultExclude
|
||||
|
||||
// Exclude the current path, and skip the rest of the dir.
|
||||
// If path is a dir, skip the current directory.
|
||||
// If path is a file, skip the rest of the parent directory.
|
||||
// (This matches the semantics of fs.SkipDir.)
|
||||
MapResultSkipDir
|
||||
)
|
||||
|
||||
func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) error {
|
||||
root, err := filepath.EvalSymlinks(p)
|
||||
if err != nil {
|
||||
@ -258,7 +278,10 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return ctx.Err()
|
||||
default:
|
||||
if opt != nil && opt.Map != nil {
|
||||
if allowed := opt.Map(stat.Path, stat); !allowed {
|
||||
result := opt.Map(stat.Path, stat)
|
||||
if result == MapResultSkipDir {
|
||||
return filepath.SkipDir
|
||||
} else if result == MapResultExclude {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -277,7 +300,8 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
default:
|
||||
}
|
||||
if opt != nil && opt.Map != nil {
|
||||
if allowed := opt.Map(parentStat.Path, parentStat); !allowed {
|
||||
result := opt.Map(parentStat.Path, parentStat)
|
||||
if result == MapResultSkipDir || result == MapResultExclude {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user