diff --git a/devices/devices_windows.go b/devices/devices_windows.go index 04627c80..cd551f53 100644 --- a/devices/devices_windows.go +++ b/devices/devices_windows.go @@ -17,11 +17,10 @@ package devices import ( + "fmt" "os" - - "github.com/pkg/errors" ) func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) { - return 0, 0, errors.Wrap(ErrNotSupported, "cannot get device info on windows") + return 0, 0, fmt.Errorf("cannot get device info on windows: %w", ErrNotSupported) } diff --git a/fs/copy.go b/fs/copy.go index 2ee77d1a..514ff3f4 100644 --- a/fs/copy.go +++ b/fs/copy.go @@ -17,12 +17,11 @@ package fs import ( + "fmt" "io/ioutil" "os" "path/filepath" "sync" - - "github.com/pkg/errors" ) var bufferPool = &sync.Pool{ @@ -92,35 +91,35 @@ func CopyDir(dst, src string, opts ...CopyDirOpt) error { func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) error { stat, err := os.Stat(src) if err != nil { - return errors.Wrapf(err, "failed to stat %s", src) + return fmt.Errorf("failed to stat %s: %w", src, err) } if !stat.IsDir() { - return errors.Errorf("source %s is not directory", src) + return fmt.Errorf("source %s is not directory", src) } if st, err := os.Stat(dst); err != nil { if err := os.Mkdir(dst, stat.Mode()); err != nil { - return errors.Wrapf(err, "failed to mkdir %s", dst) + return fmt.Errorf("failed to mkdir %s: %w", dst, err) } } else if !st.IsDir() { - return errors.Errorf("cannot copy to non-directory: %s", dst) + return fmt.Errorf("cannot copy to non-directory: %s", dst) } else { if err := os.Chmod(dst, stat.Mode()); err != nil { - return errors.Wrapf(err, "failed to chmod on %s", dst) + return fmt.Errorf("failed to chmod on %s: %w", dst, err) } } fis, err := ioutil.ReadDir(src) if err != nil { - return errors.Wrapf(err, "failed to read %s", src) + return fmt.Errorf("failed to read %s: %w", src, err) } if err := copyFileInfo(stat, dst); err != nil { - return errors.Wrapf(err, "failed to copy file info for %s", dst) + return fmt.Errorf("failed to copy file info for %s: %w", dst, err) } if err := copyXAttrs(dst, src, o.xex, o.xeh); err != nil { - return errors.Wrap(err, "failed to copy xattrs") + return fmt.Errorf("failed to copy xattrs: %w", err) } for _, fi := range fis { @@ -136,37 +135,37 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er case (fi.Mode() & os.ModeType) == 0: link, err := getLinkSource(target, fi, inodes) if err != nil { - return errors.Wrap(err, "failed to get hardlink") + return fmt.Errorf("failed to get hardlink: %w", err) } if link != "" { if err := os.Link(link, target); err != nil { - return errors.Wrap(err, "failed to create hard link") + return fmt.Errorf("failed to create hard link: %w", err) } } else if err := CopyFile(target, source); err != nil { - return errors.Wrap(err, "failed to copy files") + return fmt.Errorf("failed to copy files: %w", err) } case (fi.Mode() & os.ModeSymlink) == os.ModeSymlink: link, err := os.Readlink(source) if err != nil { - return errors.Wrapf(err, "failed to read link: %s", source) + return fmt.Errorf("failed to read link: %s: %w", source, err) } if err := os.Symlink(link, target); err != nil { - return errors.Wrapf(err, "failed to create symlink: %s", target) + return fmt.Errorf("failed to create symlink: %s: %w", target, err) } case (fi.Mode() & os.ModeDevice) == os.ModeDevice: if err := copyDevice(target, fi); err != nil { - return errors.Wrapf(err, "failed to create device") + return fmt.Errorf("failed to create device: %w", err) } default: // TODO: Support pipes and sockets - return errors.Wrapf(err, "unsupported mode %s", fi.Mode()) + return fmt.Errorf("unsupported mode %s: %w", fi.Mode(), err) } if err := copyFileInfo(fi, target); err != nil { - return errors.Wrap(err, "failed to copy file info") + return fmt.Errorf("failed to copy file info: %w", err) } if err := copyXAttrs(target, source, o.xex, o.xeh); err != nil { - return errors.Wrap(err, "failed to copy xattrs") + return fmt.Errorf("failed to copy xattrs: %w", err) } } @@ -178,12 +177,12 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er func CopyFile(target, source string) error { src, err := os.Open(source) if err != nil { - return errors.Wrapf(err, "failed to open source %s", source) + return fmt.Errorf("failed to open source %s: %w", source, err) } defer src.Close() tgt, err := os.Create(target) if err != nil { - return errors.Wrapf(err, "failed to open target %s", target) + return fmt.Errorf("failed to open target %s: %w", target, err) } defer tgt.Close() diff --git a/fs/copy_darwinopenbsdsolaris.go b/fs/copy_darwinopenbsdsolaris.go index a9ff961b..d46f57af 100644 --- a/fs/copy_darwinopenbsdsolaris.go +++ b/fs/copy_darwinopenbsdsolaris.go @@ -20,10 +20,10 @@ package fs import ( + "errors" "os" "syscall" - "github.com/pkg/errors" "golang.org/x/sys/unix" ) diff --git a/fs/copy_freebsd.go b/fs/copy_freebsd.go index 31250cff..61af4c48 100644 --- a/fs/copy_freebsd.go +++ b/fs/copy_freebsd.go @@ -20,10 +20,10 @@ package fs import ( + "errors" "os" "syscall" - "github.com/pkg/errors" "golang.org/x/sys/unix" ) diff --git a/fs/copy_linux.go b/fs/copy_linux.go index 85beaee5..64602e07 100644 --- a/fs/copy_linux.go +++ b/fs/copy_linux.go @@ -17,12 +17,13 @@ package fs import ( + "errors" + "fmt" "io" "os" "syscall" "github.com/containerd/continuity/sysx" - "github.com/pkg/errors" "golang.org/x/sys/unix" ) @@ -41,13 +42,13 @@ func copyFileInfo(fi os.FileInfo, name string) error { } } if err != nil { - return errors.Wrapf(err, "failed to chown %s", name) + return fmt.Errorf("failed to chown %s: %w", name, err) } } if (fi.Mode() & os.ModeSymlink) != os.ModeSymlink { if err := os.Chmod(name, fi.Mode()); err != nil { - return errors.Wrapf(err, "failed to chmod %s", name) + return fmt.Errorf("failed to chmod %s: %w", name, err) } } @@ -56,7 +57,7 @@ func copyFileInfo(fi os.FileInfo, name string) error { unix.NsecToTimespec(syscall.TimespecToNsec(StatMtime(st))), } if err := unix.UtimesNanoAt(unix.AT_FDCWD, name, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil { - return errors.Wrapf(err, "failed to utime %s", name) + return fmt.Errorf("failed to utime %s: %w", name, err) } return nil @@ -67,7 +68,7 @@ const maxSSizeT = int64(^uint(0) >> 1) func copyFileContent(dst, src *os.File) error { st, err := src.Stat() if err != nil { - return errors.Wrap(err, "unable to stat source") + return fmt.Errorf("unable to stat source: %w", err) } size := st.Size() @@ -88,13 +89,13 @@ func copyFileContent(dst, src *os.File) error { n, err := unix.CopyFileRange(srcFd, nil, dstFd, nil, copySize, 0) if err != nil { if (err != unix.ENOSYS && err != unix.EXDEV) || !first { - return errors.Wrap(err, "copy file range failed") + return fmt.Errorf("copy file range failed: %w", err) } buf := bufferPool.Get().(*[]byte) _, err = io.CopyBuffer(dst, src, *buf) bufferPool.Put(buf) - return errors.Wrap(err, "userspace copy failed") + return fmt.Errorf("userspace copy failed: %w", err) } first = false @@ -107,7 +108,7 @@ func copyFileContent(dst, src *os.File) error { func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error { xattrKeys, err := sysx.LListxattr(src) if err != nil { - e := errors.Wrapf(err, "failed to list xattrs on %s", src) + e := fmt.Errorf("failed to list xattrs on %s: %w", src, err) if errorHandler != nil { e = errorHandler(dst, src, "", e) } @@ -119,7 +120,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt } data, err := sysx.LGetxattr(src, xattr) if err != nil { - e := errors.Wrapf(err, "failed to get xattr %q on %s", xattr, src) + e := fmt.Errorf("failed to get xattr %q on %s: %w", xattr, src, err) if errorHandler != nil { if e = errorHandler(dst, src, xattr, e); e == nil { continue @@ -128,7 +129,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt return e } if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil { - e := errors.Wrapf(err, "failed to set xattr %q on %s", xattr, dst) + e := fmt.Errorf("failed to set xattr %q on %s: %w", xattr, dst, err) if errorHandler != nil { if e = errorHandler(dst, src, xattr, e); e == nil { continue diff --git a/fs/copy_test.go b/fs/copy_test.go index 4f59aa4c..e27716ac 100644 --- a/fs/copy_test.go +++ b/fs/copy_test.go @@ -18,13 +18,13 @@ package fs import ( _ "crypto/sha256" + "fmt" "io/ioutil" "os" "testing" "time" "github.com/containerd/continuity/fs/fstest" - "github.com/pkg/errors" ) // TODO: Create copy directory which requires privilege @@ -80,22 +80,22 @@ func TestCopyWithLargeFile(t *testing.T) { func testCopy(apply fstest.Applier) error { t1, err := ioutil.TempDir("", "test-copy-src-") if err != nil { - return errors.Wrap(err, "failed to create temporary directory") + return fmt.Errorf("failed to create temporary directory: %w", err) } defer os.RemoveAll(t1) t2, err := ioutil.TempDir("", "test-copy-dst-") if err != nil { - return errors.Wrap(err, "failed to create temporary directory") + return fmt.Errorf("failed to create temporary directory: %w", err) } defer os.RemoveAll(t2) if err := apply.Apply(t1); err != nil { - return errors.Wrap(err, "failed to apply changes") + return fmt.Errorf("failed to apply changes: %w", err) } if err := CopyDir(t2, t1); err != nil { - return errors.Wrap(err, "failed to copy") + return fmt.Errorf("failed to copy: %w", err) } return fstest.CheckDirectoryEqual(t1, t2) diff --git a/fs/copy_unix.go b/fs/copy_unix.go index 82e78b71..4a66070a 100644 --- a/fs/copy_unix.go +++ b/fs/copy_unix.go @@ -20,12 +20,12 @@ package fs import ( + "fmt" "io" "os" "syscall" "github.com/containerd/continuity/sysx" - "github.com/pkg/errors" ) func copyFileInfo(fi os.FileInfo, name string) error { @@ -43,18 +43,18 @@ func copyFileInfo(fi os.FileInfo, name string) error { } } if err != nil { - return errors.Wrapf(err, "failed to chown %s", name) + return fmt.Errorf("failed to chown %s: %w", name, err) } } if (fi.Mode() & os.ModeSymlink) != os.ModeSymlink { if err := os.Chmod(name, fi.Mode()); err != nil { - return errors.Wrapf(err, "failed to chmod %s", name) + return fmt.Errorf("failed to chmod %s: %w", name, err) } } if err := utimesNano(name, StatAtime(st), StatMtime(st)); err != nil { - return errors.Wrapf(err, "failed to utime %s", name) + return fmt.Errorf("failed to utime %s: %w", name, err) } return nil @@ -71,7 +71,7 @@ func copyFileContent(dst, src *os.File) error { func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error { xattrKeys, err := sysx.LListxattr(src) if err != nil { - e := errors.Wrapf(err, "failed to list xattrs on %s", src) + e := fmt.Errorf("failed to list xattrs on %s: %w", src, err) if errorHandler != nil { e = errorHandler(dst, src, "", e) } @@ -83,7 +83,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt } data, err := sysx.LGetxattr(src, xattr) if err != nil { - e := errors.Wrapf(err, "failed to get xattr %q on %s", xattr, src) + e := fmt.Errorf("failed to get xattr %q on %s: %w", xattr, src, err) if errorHandler != nil { if e = errorHandler(dst, src, xattr, e); e == nil { continue @@ -92,7 +92,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt return e } if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil { - e := errors.Wrapf(err, "failed to set xattr %q on %s", xattr, dst) + e := fmt.Errorf("failed to set xattr %q on %s: %w", xattr, dst, err) if errorHandler != nil { if e = errorHandler(dst, src, xattr, e); e == nil { continue diff --git a/fs/copy_windows.go b/fs/copy_windows.go index 0081583f..b2389210 100644 --- a/fs/copy_windows.go +++ b/fs/copy_windows.go @@ -17,15 +17,15 @@ package fs import ( + "errors" + "fmt" "io" "os" - - "github.com/pkg/errors" ) func copyFileInfo(fi os.FileInfo, name string) error { if err := os.Chmod(name, fi.Mode()); err != nil { - return errors.Wrapf(err, "failed to chmod %s", name) + return fmt.Errorf("failed to chmod %s: %w", name, err) } // TODO: copy windows specific metadata diff --git a/fs/diff_test.go b/fs/diff_test.go index adb93539..f63be231 100644 --- a/fs/diff_test.go +++ b/fs/diff_test.go @@ -28,7 +28,6 @@ import ( "time" "github.com/containerd/continuity/fs/fstest" - "github.com/pkg/errors" ) // TODO: Additional tests @@ -293,30 +292,30 @@ func TestLchtimes(t *testing.T) { func testDiffWithBase(base, diff fstest.Applier, expected []TestChange) error { t1, err := ioutil.TempDir("", "diff-with-base-lower-") if err != nil { - return errors.Wrap(err, "failed to create temp dir") + return fmt.Errorf("failed to create temp dir: %w", err) } defer os.RemoveAll(t1) t2, err := ioutil.TempDir("", "diff-with-base-upper-") if err != nil { - return errors.Wrap(err, "failed to create temp dir") + return fmt.Errorf("failed to create temp dir: %w", err) } defer os.RemoveAll(t2) if err := base.Apply(t1); err != nil { - return errors.Wrap(err, "failed to apply base filesystem") + return fmt.Errorf("failed to apply base filesystem: %w", err) } if err := CopyDir(t2, t1); err != nil { - return errors.Wrap(err, "failed to copy base directory") + return fmt.Errorf("failed to copy base directory: %w", err) } if err := diff.Apply(t2); err != nil { - return errors.Wrap(err, "failed to apply diff filesystem") + return fmt.Errorf("failed to apply diff filesystem: %w", err) } changes, err := collectChanges(t1, t2) if err != nil { - return errors.Wrap(err, "failed to collect changes") + return fmt.Errorf("failed to collect changes: %w", err) } return checkChanges(t2, changes, expected) @@ -346,17 +345,17 @@ func TestBaseDirectoryChanges(t *testing.T) { func testDiffWithoutBase(apply fstest.Applier, expected []TestChange) error { tmp, err := ioutil.TempDir("", "diff-without-base-") if err != nil { - return errors.Wrap(err, "failed to create temp dir") + return fmt.Errorf("failed to create temp dir: %w", err) } defer os.RemoveAll(tmp) if err := apply.Apply(tmp); err != nil { - return errors.Wrap(err, "failed to apply filesytem changes") + return fmt.Errorf("failed to apply filesytem changes: %w", err) } changes, err := collectChanges("", tmp) if err != nil { - return errors.Wrap(err, "failed to collect changes") + return fmt.Errorf("failed to collect changes: %w", err) } return checkChanges(tmp, changes, expected) @@ -364,30 +363,30 @@ func testDiffWithoutBase(apply fstest.Applier, expected []TestChange) error { func checkChanges(root string, changes, expected []TestChange) error { if len(changes) != len(expected) { - return errors.Errorf("Unexpected number of changes:\n%s", diffString(changes, expected)) + return fmt.Errorf("Unexpected number of changes:\n%s", diffString(changes, expected)) } for i := range changes { if changes[i].Path != expected[i].Path || changes[i].Kind != expected[i].Kind { - return errors.Errorf("Unexpected change at %d:\n%s", i, diffString(changes, expected)) + return fmt.Errorf("Unexpected change at %d:\n%s", i, diffString(changes, expected)) } if changes[i].Kind != ChangeKindDelete { filename := filepath.Join(root, changes[i].Path) efi, err := os.Stat(filename) if err != nil { - return errors.Wrapf(err, "failed to stat %q", filename) + return fmt.Errorf("failed to stat %q: %w", filename, err) } afi := changes[i].FileInfo if afi.Size() != efi.Size() { - return errors.Errorf("Unexpected change size %d, %q has size %d", afi.Size(), filename, efi.Size()) + return fmt.Errorf("Unexpected change size %d, %q has size %d", afi.Size(), filename, efi.Size()) } if afi.Mode() != efi.Mode() { - return errors.Errorf("Unexpected change mode %s, %q has mode %s", afi.Mode(), filename, efi.Mode()) + return fmt.Errorf("Unexpected change mode %s, %q has mode %s", afi.Mode(), filename, efi.Mode()) } if afi.ModTime() != efi.ModTime() { - return errors.Errorf("Unexpected change modtime %s, %q has modtime %s", afi.ModTime(), filename, efi.ModTime()) + return fmt.Errorf("Unexpected change modtime %s, %q has modtime %s", afi.ModTime(), filename, efi.ModTime()) } if expected := filepath.Join(root, changes[i].Path); changes[i].Source != expected { - return errors.Errorf("Unexpected source path %s, expected %s", changes[i].Source, expected) + return fmt.Errorf("Unexpected source path %s, expected %s", changes[i].Source, expected) } } } @@ -417,7 +416,7 @@ func collectChanges(a, b string) ([]TestChange, error) { return nil }) if err != nil { - return nil, errors.Wrap(err, "failed to compute changes") + return nil, fmt.Errorf("failed to compute changes: %w", err) } return changes, nil diff --git a/fs/diff_unix.go b/fs/diff_unix.go index e84afb4f..5de9b6b4 100644 --- a/fs/diff_unix.go +++ b/fs/diff_unix.go @@ -21,11 +21,11 @@ package fs import ( "bytes" + "fmt" "os" "syscall" "github.com/containerd/continuity/sysx" - "github.com/pkg/errors" ) // detectDirDiff returns diff dir options if a directory could @@ -57,11 +57,11 @@ func compareSysStat(s1, s2 interface{}) (bool, error) { func compareCapabilities(p1, p2 string) (bool, error) { c1, err := sysx.LGetxattr(p1, "security.capability") if err != nil && err != sysx.ENODATA { - return false, errors.Wrapf(err, "failed to get xattr for %s", p1) + return false, fmt.Errorf("failed to get xattr for %s: %w", p1, err) } c2, err := sysx.LGetxattr(p2, "security.capability") if err != nil && err != sysx.ENODATA { - return false, errors.Wrapf(err, "failed to get xattr for %s", p2) + return false, fmt.Errorf("failed to get xattr for %s: %w", p2, err) } return bytes.Equal(c1, c2), nil } diff --git a/fs/du_test.go b/fs/du_test.go index 33c9b632..7b1e8c1b 100644 --- a/fs/du_test.go +++ b/fs/du_test.go @@ -18,6 +18,7 @@ package fs import ( "context" + "errors" "io" "io/ioutil" "math/rand" @@ -27,7 +28,6 @@ import ( "testing" "github.com/containerd/continuity/fs/fstest" - "github.com/pkg/errors" ) var errNotImplemented = errors.New("check not implemented") diff --git a/fs/du_unix_test.go b/fs/du_unix_test.go index 4cac7328..e2d293c2 100644 --- a/fs/du_unix_test.go +++ b/fs/du_unix_test.go @@ -20,13 +20,13 @@ package fs import ( + "errors" + "fmt" "io/ioutil" "os" "strconv" "strings" "syscall" - - "github.com/pkg/errors" ) func getBsize(root string) (int64, error) { @@ -44,13 +44,13 @@ func getBsize(root string) (int64, error) { func getTmpAlign() (func(int64) int64, func(int64) int64, error) { t1, err := ioutil.TempDir("", "compute-align-") if err != nil { - return nil, nil, errors.Wrap(err, "failed to create temp dir") + return nil, nil, fmt.Errorf("failed to create temp dir: %w", err) } defer os.RemoveAll(t1) bsize, err := getBsize(t1) if err != nil { - return nil, nil, errors.Wrap(err, "failed to get bsize") + return nil, nil, fmt.Errorf("failed to get bsize: %w", err) } align := func(size int64) int64 { @@ -67,7 +67,7 @@ func getTmpAlign() (func(int64) int64, func(int64) int64, error) { fi, err := os.Stat(t1) if err != nil { - return nil, nil, errors.Wrap(err, "failed to stat directory") + return nil, nil, fmt.Errorf("failed to stat directory: %w", err) } dirSize := fi.Sys().(*syscall.Stat_t).Blocks * blocksUnitSize diff --git a/fs/fstest/compare.go b/fs/fstest/compare.go index 0d100b62..5ae167e5 100644 --- a/fs/fstest/compare.go +++ b/fs/fstest/compare.go @@ -17,11 +17,11 @@ package fstest import ( + "fmt" "io/ioutil" "os" "github.com/containerd/continuity" - "github.com/pkg/errors" ) // CheckDirectoryEqual compares two directory paths to make sure that @@ -29,27 +29,27 @@ import ( func CheckDirectoryEqual(d1, d2 string) error { c1, err := continuity.NewContext(d1) if err != nil { - return errors.Wrap(err, "failed to build context") + return fmt.Errorf("failed to build context: %w", err) } c2, err := continuity.NewContext(d2) if err != nil { - return errors.Wrap(err, "failed to build context") + return fmt.Errorf("failed to build context: %w", err) } m1, err := continuity.BuildManifest(c1) if err != nil { - return errors.Wrap(err, "failed to build manifest") + return fmt.Errorf("failed to build manifest: %w", err) } m2, err := continuity.BuildManifest(c2) if err != nil { - return errors.Wrap(err, "failed to build manifest") + return fmt.Errorf("failed to build manifest: %w", err) } diff := diffResourceList(m1.Resources, m2.Resources) if diff.HasDiff() { - return errors.Errorf("directory diff between %s and %s\n%s", d1, d2, diff.String()) + return fmt.Errorf("directory diff between %s and %s\n%s", d1, d2, diff.String()) } return nil diff --git a/fs/fstest/file_windows.go b/fs/fstest/file_windows.go index 1fab035b..45fd9f61 100644 --- a/fs/fstest/file_windows.go +++ b/fs/fstest/file_windows.go @@ -17,9 +17,8 @@ package fstest import ( + "errors" "time" - - "github.com/pkg/errors" ) // Lchtimes changes access and mod time of file without following symlink diff --git a/fs/path.go b/fs/path.go index c26be798..97313e2b 100644 --- a/fs/path.go +++ b/fs/path.go @@ -19,11 +19,10 @@ package fs import ( "bytes" "context" + "errors" "io" "os" "path/filepath" - - "github.com/pkg/errors" ) var ( diff --git a/fs/path_test.go b/fs/path_test.go index 26fc1e79..83b154f6 100644 --- a/fs/path_test.go +++ b/fs/path_test.go @@ -20,13 +20,13 @@ package fs import ( + "errors" "io/ioutil" "os" "path/filepath" "testing" "github.com/containerd/continuity/fs/fstest" - "github.com/pkg/errors" ) type RootCheck struct { diff --git a/go.mod b/go.mod index 5ee58d75..45aeb3ed 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/dustin/go-humanize v1.0.0 github.com/golang/protobuf v1.3.5 github.com/opencontainers/go-digest v1.0.0 - github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.7.0 github.com/spf13/cobra v1.0.0 golang.org/x/sync v0.0.0-20201207232520-09787c993a3a diff --git a/go.sum b/go.sum index c85814ad..95984d22 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,6 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -115,7 +113,6 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/testutil/loopback/loopback_linux.go b/testutil/loopback/loopback_linux.go index 25629a87..a43a70e7 100644 --- a/testutil/loopback/loopback_linux.go +++ b/testutil/loopback/loopback_linux.go @@ -21,13 +21,14 @@ package loopback import ( "bytes" + "errors" + "fmt" "io/ioutil" "os" "os/exec" "strings" "syscall" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -36,13 +37,13 @@ func New(size int64) (*Loopback, error) { // create temporary file for the disk image file, err := ioutil.TempFile("", "containerd-test-loopback") if err != nil { - return nil, errors.Wrap(err, "could not create temporary file for loopback") + return nil, fmt.Errorf("could not create temporary file for loopback: %w", err) } if err := file.Truncate(size); err != nil { file.Close() os.Remove(file.Name()) - return nil, errors.Wrap(err, "failed to resize temp file") + return nil, fmt.Errorf("failed to resize temp file: %w", err) } file.Close() @@ -53,8 +54,7 @@ func New(size int64) (*Loopback, error) { losetup.Stderr = &stderr if err := losetup.Run(); err != nil { os.Remove(file.Name()) - return nil, errors.Wrapf(err, "loopback setup failed (%v): stdout=%q, stderr=%q", - losetup.Args, stdout.String(), stderr.String()) + return nil, fmt.Errorf("loopback setup failed (%v): stdout=%q, stderr=%q: %w", losetup.Args, stdout.String(), stderr.String(), err) } deviceName := strings.TrimSpace(stdout.String()) @@ -65,8 +65,7 @@ func New(size int64) (*Loopback, error) { logrus.Debugf("Removing loop device %s", deviceName) losetup := exec.Command("losetup", "--detach", deviceName) if out, err := losetup.CombinedOutput(); err != nil { - return errors.Wrapf(err, "Could not remove loop device %s (%v): %q", - deviceName, losetup.Args, string(out)) + return fmt.Errorf("Could not remove loop device %s (%v): %q: %w", deviceName, losetup.Args, string(out), err) } // remove file diff --git a/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore deleted file mode 100644 index daf913b1..00000000 --- a/vendor/github.com/pkg/errors/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml deleted file mode 100644 index 9159de03..00000000 --- a/vendor/github.com/pkg/errors/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: go -go_import_path: github.com/pkg/errors -go: - - 1.11.x - - 1.12.x - - 1.13.x - - tip - -script: - - make check diff --git a/vendor/github.com/pkg/errors/LICENSE b/vendor/github.com/pkg/errors/LICENSE deleted file mode 100644 index 835ba3e7..00000000 --- a/vendor/github.com/pkg/errors/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2015, Dave Cheney -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pkg/errors/Makefile b/vendor/github.com/pkg/errors/Makefile deleted file mode 100644 index ce9d7cde..00000000 --- a/vendor/github.com/pkg/errors/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -PKGS := github.com/pkg/errors -SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) -GO := go - -check: test vet gofmt misspell unconvert staticcheck ineffassign unparam - -test: - $(GO) test $(PKGS) - -vet: | test - $(GO) vet $(PKGS) - -staticcheck: - $(GO) get honnef.co/go/tools/cmd/staticcheck - staticcheck -checks all $(PKGS) - -misspell: - $(GO) get github.com/client9/misspell/cmd/misspell - misspell \ - -locale GB \ - -error \ - *.md *.go - -unconvert: - $(GO) get github.com/mdempsky/unconvert - unconvert -v $(PKGS) - -ineffassign: - $(GO) get github.com/gordonklaus/ineffassign - find $(SRCDIRS) -name '*.go' | xargs ineffassign - -pedantic: check errcheck - -unparam: - $(GO) get mvdan.cc/unparam - unparam ./... - -errcheck: - $(GO) get github.com/kisielk/errcheck - errcheck $(PKGS) - -gofmt: - @echo Checking code is gofmted - @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md deleted file mode 100644 index 54dfdcb1..00000000 --- a/vendor/github.com/pkg/errors/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) - -Package errors provides simple error handling primitives. - -`go get github.com/pkg/errors` - -The traditional error handling idiom in Go is roughly akin to -```go -if err != nil { - return err -} -``` -which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. - -## Adding context to an error - -The errors.Wrap function returns a new error that adds context to the original error. For example -```go -_, err := ioutil.ReadAll(r) -if err != nil { - return errors.Wrap(err, "read failed") -} -``` -## Retrieving the cause of an error - -Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. -```go -type causer interface { - Cause() error -} -``` -`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: -```go -switch err := errors.Cause(err).(type) { -case *MyError: - // handle specifically -default: - // unknown error -} -``` - -[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). - -## Roadmap - -With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: - -- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) -- 1.0. Final release. - -## Contributing - -Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. - -Before sending a PR, please discuss your change by raising an issue. - -## License - -BSD-2-Clause diff --git a/vendor/github.com/pkg/errors/appveyor.yml b/vendor/github.com/pkg/errors/appveyor.yml deleted file mode 100644 index a932eade..00000000 --- a/vendor/github.com/pkg/errors/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\pkg\errors -shallow_clone: true # for startup speed - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -# http://www.appveyor.com/docs/installed-software -install: - # some helpful output for debugging builds - - go version - - go env - # pre-installed MinGW at C:\MinGW is 32bit only - # but MSYS2 at C:\msys64 has mingw64 - - set PATH=C:\msys64\mingw64\bin;%PATH% - - gcc --version - - g++ --version - -build_script: - - go install -v ./... - -test_script: - - set PATH=C:\gopath\bin;%PATH% - - go test -v ./... - -#artifacts: -# - path: '%GOPATH%\bin\*.exe' -deploy: off diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go deleted file mode 100644 index 161aea25..00000000 --- a/vendor/github.com/pkg/errors/errors.go +++ /dev/null @@ -1,288 +0,0 @@ -// Package errors provides simple error handling primitives. -// -// The traditional error handling idiom in Go is roughly akin to -// -// if err != nil { -// return err -// } -// -// which when applied recursively up the call stack results in error reports -// without context or debugging information. The errors package allows -// programmers to add context to the failure path in their code in a way -// that does not destroy the original value of the error. -// -// Adding context to an error -// -// The errors.Wrap function returns a new error that adds context to the -// original error by recording a stack trace at the point Wrap is called, -// together with the supplied message. For example -// -// _, err := ioutil.ReadAll(r) -// if err != nil { -// return errors.Wrap(err, "read failed") -// } -// -// If additional control is required, the errors.WithStack and -// errors.WithMessage functions destructure errors.Wrap into its component -// operations: annotating an error with a stack trace and with a message, -// respectively. -// -// Retrieving the cause of an error -// -// Using errors.Wrap constructs a stack of errors, adding context to the -// preceding error. Depending on the nature of the error it may be necessary -// to reverse the operation of errors.Wrap to retrieve the original error -// for inspection. Any error value which implements this interface -// -// type causer interface { -// Cause() error -// } -// -// can be inspected by errors.Cause. errors.Cause will recursively retrieve -// the topmost error that does not implement causer, which is assumed to be -// the original cause. For example: -// -// switch err := errors.Cause(err).(type) { -// case *MyError: -// // handle specifically -// default: -// // unknown error -// } -// -// Although the causer interface is not exported by this package, it is -// considered a part of its stable public interface. -// -// Formatted printing of errors -// -// All error values returned from this package implement fmt.Formatter and can -// be formatted by the fmt package. The following verbs are supported: -// -// %s print the error. If the error has a Cause it will be -// printed recursively. -// %v see %s -// %+v extended format. Each Frame of the error's StackTrace will -// be printed in detail. -// -// Retrieving the stack trace of an error or wrapper -// -// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are -// invoked. This information can be retrieved with the following interface: -// -// type stackTracer interface { -// StackTrace() errors.StackTrace -// } -// -// The returned errors.StackTrace type is defined as -// -// type StackTrace []Frame -// -// The Frame type represents a call site in the stack trace. Frame supports -// the fmt.Formatter interface that can be used for printing information about -// the stack trace of this error. For example: -// -// if err, ok := err.(stackTracer); ok { -// for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d\n", f, f) -// } -// } -// -// Although the stackTracer interface is not exported by this package, it is -// considered a part of its stable public interface. -// -// See the documentation for Frame.Format for more details. -package errors - -import ( - "fmt" - "io" -) - -// New returns an error with the supplied message. -// New also records the stack trace at the point it was called. -func New(message string) error { - return &fundamental{ - msg: message, - stack: callers(), - } -} - -// Errorf formats according to a format specifier and returns the string -// as a value that satisfies error. -// Errorf also records the stack trace at the point it was called. -func Errorf(format string, args ...interface{}) error { - return &fundamental{ - msg: fmt.Sprintf(format, args...), - stack: callers(), - } -} - -// fundamental is an error that has a message and a stack, but no caller. -type fundamental struct { - msg string - *stack -} - -func (f *fundamental) Error() string { return f.msg } - -func (f *fundamental) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - io.WriteString(s, f.msg) - f.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, f.msg) - case 'q': - fmt.Fprintf(s, "%q", f.msg) - } -} - -// WithStack annotates err with a stack trace at the point WithStack was called. -// If err is nil, WithStack returns nil. -func WithStack(err error) error { - if err == nil { - return nil - } - return &withStack{ - err, - callers(), - } -} - -type withStack struct { - error - *stack -} - -func (w *withStack) Cause() error { return w.error } - -// Unwrap provides compatibility for Go 1.13 error chains. -func (w *withStack) Unwrap() error { return w.error } - -func (w *withStack) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v", w.Cause()) - w.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, w.Error()) - case 'q': - fmt.Fprintf(s, "%q", w.Error()) - } -} - -// Wrap returns an error annotating err with a stack trace -// at the point Wrap is called, and the supplied message. -// If err is nil, Wrap returns nil. -func Wrap(err error, message string) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: message, - } - return &withStack{ - err, - callers(), - } -} - -// Wrapf returns an error annotating err with a stack trace -// at the point Wrapf is called, and the format specifier. -// If err is nil, Wrapf returns nil. -func Wrapf(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } - return &withStack{ - err, - callers(), - } -} - -// WithMessage annotates err with a new message. -// If err is nil, WithMessage returns nil. -func WithMessage(err error, message string) error { - if err == nil { - return nil - } - return &withMessage{ - cause: err, - msg: message, - } -} - -// WithMessagef annotates err with the format specifier. -// If err is nil, WithMessagef returns nil. -func WithMessagef(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - return &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } -} - -type withMessage struct { - cause error - msg string -} - -func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } -func (w *withMessage) Cause() error { return w.cause } - -// Unwrap provides compatibility for Go 1.13 error chains. -func (w *withMessage) Unwrap() error { return w.cause } - -func (w *withMessage) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v\n", w.Cause()) - io.WriteString(s, w.msg) - return - } - fallthrough - case 's', 'q': - io.WriteString(s, w.Error()) - } -} - -// Cause returns the underlying cause of the error, if possible. -// An error value has a cause if it implements the following -// interface: -// -// type causer interface { -// Cause() error -// } -// -// If the error does not implement Cause, the original error will -// be returned. If the error is nil, nil will be returned without further -// investigation. -func Cause(err error) error { - type causer interface { - Cause() error - } - - for err != nil { - cause, ok := err.(causer) - if !ok { - break - } - err = cause.Cause() - } - return err -} diff --git a/vendor/github.com/pkg/errors/go113.go b/vendor/github.com/pkg/errors/go113.go deleted file mode 100644 index be0d10d0..00000000 --- a/vendor/github.com/pkg/errors/go113.go +++ /dev/null @@ -1,38 +0,0 @@ -// +build go1.13 - -package errors - -import ( - stderrors "errors" -) - -// Is reports whether any error in err's chain matches target. -// -// The chain consists of err itself followed by the sequence of errors obtained by -// repeatedly calling Unwrap. -// -// An error is considered to match a target if it is equal to that target or if -// it implements a method Is(error) bool such that Is(target) returns true. -func Is(err, target error) bool { return stderrors.Is(err, target) } - -// As finds the first error in err's chain that matches target, and if so, sets -// target to that error value and returns true. -// -// The chain consists of err itself followed by the sequence of errors obtained by -// repeatedly calling Unwrap. -// -// An error matches target if the error's concrete value is assignable to the value -// pointed to by target, or if the error has a method As(interface{}) bool such that -// As(target) returns true. In the latter case, the As method is responsible for -// setting target. -// -// As will panic if target is not a non-nil pointer to either a type that implements -// error, or to any interface type. As returns false if err is nil. -func As(err error, target interface{}) bool { return stderrors.As(err, target) } - -// Unwrap returns the result of calling the Unwrap method on err, if err's -// type contains an Unwrap method returning error. -// Otherwise, Unwrap returns nil. -func Unwrap(err error) error { - return stderrors.Unwrap(err) -} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go deleted file mode 100644 index 779a8348..00000000 --- a/vendor/github.com/pkg/errors/stack.go +++ /dev/null @@ -1,177 +0,0 @@ -package errors - -import ( - "fmt" - "io" - "path" - "runtime" - "strconv" - "strings" -) - -// Frame represents a program counter inside a stack frame. -// For historical reasons if Frame is interpreted as a uintptr -// its value represents the program counter + 1. -type Frame uintptr - -// pc returns the program counter for this frame; -// multiple frames may have the same PC value. -func (f Frame) pc() uintptr { return uintptr(f) - 1 } - -// file returns the full path to the file that contains the -// function for this Frame's pc. -func (f Frame) file() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - file, _ := fn.FileLine(f.pc()) - return file -} - -// line returns the line number of source code of the -// function for this Frame's pc. -func (f Frame) line() int { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return 0 - } - _, line := fn.FileLine(f.pc()) - return line -} - -// name returns the name of this function, if known. -func (f Frame) name() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - return fn.Name() -} - -// Format formats the frame according to the fmt.Formatter interface. -// -// %s source file -// %d source line -// %n function name -// %v equivalent to %s:%d -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+s function name and path of source file relative to the compile time -// GOPATH separated by \n\t (\n\t) -// %+v equivalent to %+s:%d -func (f Frame) Format(s fmt.State, verb rune) { - switch verb { - case 's': - switch { - case s.Flag('+'): - io.WriteString(s, f.name()) - io.WriteString(s, "\n\t") - io.WriteString(s, f.file()) - default: - io.WriteString(s, path.Base(f.file())) - } - case 'd': - io.WriteString(s, strconv.Itoa(f.line())) - case 'n': - io.WriteString(s, funcname(f.name())) - case 'v': - f.Format(s, 's') - io.WriteString(s, ":") - f.Format(s, 'd') - } -} - -// MarshalText formats a stacktrace Frame as a text string. The output is the -// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. -func (f Frame) MarshalText() ([]byte, error) { - name := f.name() - if name == "unknown" { - return []byte(name), nil - } - return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil -} - -// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). -type StackTrace []Frame - -// Format formats the stack of Frames according to the fmt.Formatter interface. -// -// %s lists source files for each Frame in the stack -// %v lists the source file and line number for each Frame in the stack -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+v Prints filename, function, and line number for each Frame in the stack. -func (st StackTrace) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case s.Flag('+'): - for _, f := range st { - io.WriteString(s, "\n") - f.Format(s, verb) - } - case s.Flag('#'): - fmt.Fprintf(s, "%#v", []Frame(st)) - default: - st.formatSlice(s, verb) - } - case 's': - st.formatSlice(s, verb) - } -} - -// formatSlice will format this StackTrace into the given buffer as a slice of -// Frame, only valid when called with '%s' or '%v'. -func (st StackTrace) formatSlice(s fmt.State, verb rune) { - io.WriteString(s, "[") - for i, f := range st { - if i > 0 { - io.WriteString(s, " ") - } - f.Format(s, verb) - } - io.WriteString(s, "]") -} - -// stack represents a stack of program counters. -type stack []uintptr - -func (s *stack) Format(st fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case st.Flag('+'): - for _, pc := range *s { - f := Frame(pc) - fmt.Fprintf(st, "\n%+v", f) - } - } - } -} - -func (s *stack) StackTrace() StackTrace { - f := make([]Frame, len(*s)) - for i := 0; i < len(f); i++ { - f[i] = Frame((*s)[i]) - } - return f -} - -func callers() *stack { - const depth = 32 - var pcs [depth]uintptr - n := runtime.Callers(3, pcs[:]) - var st stack = pcs[0:n] - return &st -} - -// funcname removes the path prefix component of a function's name reported by func.Name(). -func funcname(name string) string { - i := strings.LastIndex(name, "/") - name = name[i+1:] - i = strings.Index(name, ".") - return name[i+1:] -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5fb9c67a..812c2a8d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,8 +10,6 @@ github.com/golang/protobuf/proto github.com/inconshreveable/mousetrap # github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/go-digest -# github.com/pkg/errors v0.9.1 -github.com/pkg/errors # github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus # github.com/spf13/cobra v1.0.0