vendor: update buildkit with typed errors support

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2020-06-24 22:20:05 -07:00
parent 0269388aa7
commit 2d720a1e0b
619 changed files with 38296 additions and 104947 deletions

View File

@ -25,21 +25,21 @@ type WalkOpt struct {
func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) error {
root, err := filepath.EvalSymlinks(p)
if err != nil {
return errors.Wrapf(err, "failed to resolve %s", root)
return errors.WithStack(&os.PathError{Op: "resolve", Path: root, Err: err})
}
fi, err := os.Stat(root)
if err != nil {
return errors.Wrapf(err, "failed to stat: %s", root)
return errors.WithStack(err)
}
if !fi.IsDir() {
return errors.Errorf("%s is not a directory", root)
return errors.WithStack(&os.PathError{Op: "walk", Path: root, Err: syscall.ENOTDIR})
}
var pm *fileutils.PatternMatcher
if opt != nil && opt.ExcludePatterns != nil {
pm, err = fileutils.NewPatternMatcher(opt.ExcludePatterns)
if err != nil {
return errors.Wrapf(err, "invalid excludepaths %s", opt.ExcludePatterns)
return errors.Wrapf(err, "invalid excludepatterns: %s", opt.ExcludePatterns)
}
}
@ -65,17 +65,15 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
seenFiles := make(map[uint64]string)
return filepath.Walk(root, func(path string, fi os.FileInfo, err error) (retErr error) {
if err != nil {
if os.IsNotExist(err) {
return filepath.SkipDir
}
return err
}
defer func() {
if retErr != nil && isNotExist(retErr) {
retErr = filepath.SkipDir
}
}()
if err != nil {
return err
}
origpath := path
path, err = filepath.Rel(root, path)
if err != nil {
@ -219,12 +217,5 @@ func trimUntilIndex(str, sep string, count int) string {
}
func isNotExist(err error) bool {
err = errors.Cause(err)
if os.IsNotExist(err) {
return true
}
if pe, ok := err.(*os.PathError); ok {
err = pe.Err
}
return err == syscall.ENOTDIR
return errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR)
}