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

@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"strings"
"syscall"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil/types"
@ -15,9 +16,12 @@ import (
func WriteTar(ctx context.Context, fs FS, w io.Writer) error {
tw := tar.NewWriter(w)
err := fs.Walk(ctx, func(path string, fi os.FileInfo, err error) error {
if err != nil && !errors.Is(err, os.ErrNotExist) {
return err
}
stat, ok := fi.Sys().(*types.Stat)
if !ok {
return errors.Wrapf(err, "invalid fileinfo without stat info: %s", path)
return errors.WithStack(&os.PathError{Path: path, Err: syscall.EBADMSG, Op: "fileinfo without stat info"})
}
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
if err != nil {
@ -37,7 +41,7 @@ func WriteTar(ctx context.Context, fs FS, w io.Writer) error {
hdr.Linkname = stat.Linkname
if hdr.Linkname != "" {
hdr.Size = 0
if fi.Mode() & os.ModeSymlink != 0 {
if fi.Mode()&os.ModeSymlink != 0 {
hdr.Typeflag = tar.TypeSymlink
} else {
hdr.Typeflag = tar.TypeLink
@ -52,7 +56,7 @@ func WriteTar(ctx context.Context, fs FS, w io.Writer) error {
}
if err := tw.WriteHeader(hdr); err != nil {
return errors.Wrap(err, "failed to write file header")
return errors.Wrapf(err, "failed to write file header %s", name)
}
if hdr.Typeflag == tar.TypeReg && hdr.Size > 0 && hdr.Linkname == "" {
@ -61,10 +65,10 @@ func WriteTar(ctx context.Context, fs FS, w io.Writer) error {
return err
}
if _, err := io.Copy(tw, rc); err != nil {
return err
return errors.WithStack(err)
}
if err := rc.Close(); err != nil {
return err
return errors.WithStack(err)
}
}
return nil