Merge pull request #6033 from zouyee/continuity

bump continuity and console version  that remove pkg/errors
This commit is contained in:
Akihiro Suda 2021-09-22 00:49:49 +09:00 committed by GitHub
commit 3393970dd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 96 additions and 77 deletions

2
go.mod
View File

@ -11,7 +11,7 @@ require (
github.com/containerd/cgroups v1.0.1 github.com/containerd/cgroups v1.0.1
github.com/containerd/console v1.0.3 github.com/containerd/console v1.0.3
github.com/containerd/containerd/api v0.0.0 github.com/containerd/containerd/api v0.0.0
github.com/containerd/continuity v0.1.1-0.20210910181051-2e0898a8e801 github.com/containerd/continuity v0.2.0
github.com/containerd/fifo v1.0.0 github.com/containerd/fifo v1.0.0
github.com/containerd/go-cni v1.0.2 github.com/containerd/go-cni v1.0.2
github.com/containerd/go-runc v1.0.0 github.com/containerd/go-runc v1.0.0

4
go.sum
View File

@ -112,8 +112,8 @@ github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8a
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ=
github.com/containerd/continuity v0.1.1-0.20210910181051-2e0898a8e801 h1:JKh6jHPjtcqEVLsZ2vSC34Er40Bj/Fdq9ROGPuiQPLg= github.com/containerd/continuity v0.2.0 h1:j/9Wnn+hrEWjLvHuIxUU1YI5JjEjVlT2AA68cse9rwY=
github.com/containerd/continuity v0.1.1-0.20210910181051-2e0898a8e801/go.mod h1:51Oa4sEFsAGujlzNbDPNB0hC1utY7N91xOzW161q5nE= github.com/containerd/continuity v0.2.0/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg=
github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU= github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU=
github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4=
github.com/containerd/go-cni v1.0.2 h1:YbJAhpTevL2v6u8JC1NhCYRwf+3Vzxcc5vGnYoJ7VeE= github.com/containerd/go-cni v1.0.2 h1:YbJAhpTevL2v6u8JC1NhCYRwf+3Vzxcc5vGnYoJ7VeE=

View File

@ -109,8 +109,8 @@ github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8a
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ=
github.com/containerd/continuity v0.1.1-0.20210910181051-2e0898a8e801 h1:JKh6jHPjtcqEVLsZ2vSC34Er40Bj/Fdq9ROGPuiQPLg= github.com/containerd/continuity v0.2.0 h1:j/9Wnn+hrEWjLvHuIxUU1YI5JjEjVlT2AA68cse9rwY=
github.com/containerd/continuity v0.1.1-0.20210910181051-2e0898a8e801/go.mod h1:51Oa4sEFsAGujlzNbDPNB0hC1utY7N91xOzW161q5nE= github.com/containerd/continuity v0.2.0/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg=
github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU= github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU=
github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4=
github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb1aZGrrohk= github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb1aZGrrohk=

View File

@ -1,3 +1,4 @@
//go:build linux || darwin || freebsd || solaris
// +build linux darwin freebsd solaris // +build linux darwin freebsd solaris
/* /*

View File

@ -17,11 +17,10 @@
package devices package devices
import ( import (
"fmt"
"os" "os"
"github.com/pkg/errors"
) )
func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) { 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)
} }

View File

@ -1,3 +1,4 @@
//go:build freebsd
// +build freebsd // +build freebsd
/* /*

View File

@ -1,3 +1,4 @@
//go:build linux || darwin || solaris
// +build linux darwin solaris // +build linux darwin solaris
/* /*

View File

@ -1,3 +1,4 @@
//go:build linux || darwin || freebsd || solaris
// +build linux darwin freebsd solaris // +build linux darwin freebsd solaris
/* /*

View File

@ -1,3 +1,4 @@
//go:build go1.13
// +build go1.13 // +build go1.13
/* /*

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || solaris
// +build darwin freebsd solaris // +build darwin freebsd solaris
/* /*

View File

@ -17,12 +17,11 @@
package fs package fs
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
"github.com/pkg/errors"
) )
var bufferPool = &sync.Pool{ 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 { func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) error {
stat, err := os.Stat(src) stat, err := os.Stat(src)
if err != nil { 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() { 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 st, err := os.Stat(dst); err != nil {
if err := os.Mkdir(dst, stat.Mode()); 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() { } 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 { } else {
if err := os.Chmod(dst, stat.Mode()); err != nil { 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) fis, err := ioutil.ReadDir(src)
if err != nil { 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 { 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 { 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 { 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: case (fi.Mode() & os.ModeType) == 0:
link, err := getLinkSource(target, fi, inodes) link, err := getLinkSource(target, fi, inodes)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to get hardlink") return fmt.Errorf("failed to get hardlink: %w", err)
} }
if link != "" { if link != "" {
if err := os.Link(link, target); err != nil { 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 { } 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: case (fi.Mode() & os.ModeSymlink) == os.ModeSymlink:
link, err := os.Readlink(source) link, err := os.Readlink(source)
if err != nil { 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 { 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: case (fi.Mode() & os.ModeDevice) == os.ModeDevice:
if err := copyDevice(target, fi); err != nil { 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: default:
// TODO: Support pipes and sockets // 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 { 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 { 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 { func CopyFile(target, source string) error {
src, err := os.Open(source) src, err := os.Open(source)
if err != nil { 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() defer src.Close()
tgt, err := os.Create(target) tgt, err := os.Create(target)
if err != nil { 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() defer tgt.Close()

View File

@ -1,3 +1,4 @@
//go:build darwin
// +build darwin // +build darwin
/* /*
@ -19,10 +20,10 @@
package fs package fs
import ( import (
"errors"
"os" "os"
"syscall" "syscall"
"github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View File

@ -1,3 +1,4 @@
//go:build freebsd
// +build freebsd // +build freebsd
/* /*
@ -19,10 +20,10 @@
package fs package fs
import ( import (
"errors"
"os" "os"
"syscall" "syscall"
"github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View File

@ -17,12 +17,13 @@
package fs package fs
import ( import (
"errors"
"fmt"
"io" "io"
"os" "os"
"syscall" "syscall"
"github.com/containerd/continuity/sysx" "github.com/containerd/continuity/sysx"
"github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -41,13 +42,13 @@ func copyFileInfo(fi os.FileInfo, name string) error {
} }
} }
if err != nil { 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 (fi.Mode() & os.ModeSymlink) != os.ModeSymlink {
if err := os.Chmod(name, fi.Mode()); err != nil { 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))), unix.NsecToTimespec(syscall.TimespecToNsec(StatMtime(st))),
} }
if err := unix.UtimesNanoAt(unix.AT_FDCWD, name, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil { 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 return nil
@ -67,7 +68,7 @@ const maxSSizeT = int64(^uint(0) >> 1)
func copyFileContent(dst, src *os.File) error { func copyFileContent(dst, src *os.File) error {
st, err := src.Stat() st, err := src.Stat()
if err != nil { if err != nil {
return errors.Wrap(err, "unable to stat source") return fmt.Errorf("unable to stat source: %w", err)
} }
size := st.Size() size := st.Size()
@ -88,13 +89,13 @@ func copyFileContent(dst, src *os.File) error {
n, err := unix.CopyFileRange(srcFd, nil, dstFd, nil, copySize, 0) n, err := unix.CopyFileRange(srcFd, nil, dstFd, nil, copySize, 0)
if err != nil { if err != nil {
if (err != unix.ENOSYS && err != unix.EXDEV) || !first { 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) buf := bufferPool.Get().(*[]byte)
_, err = io.CopyBuffer(dst, src, *buf) _, err = io.CopyBuffer(dst, src, *buf)
bufferPool.Put(buf) bufferPool.Put(buf)
return errors.Wrap(err, "userspace copy failed") return fmt.Errorf("userspace copy failed: %w", err)
} }
first = false 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 { func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
xattrKeys, err := sysx.LListxattr(src) xattrKeys, err := sysx.LListxattr(src)
if err != nil { 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 { if errorHandler != nil {
e = errorHandler(dst, src, "", e) 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) data, err := sysx.LGetxattr(src, xattr)
if err != nil { 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 errorHandler != nil {
if e = errorHandler(dst, src, xattr, e); e == nil { if e = errorHandler(dst, src, xattr, e); e == nil {
continue continue
@ -128,7 +129,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
return e return e
} }
if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil { 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 errorHandler != nil {
if e = errorHandler(dst, src, xattr, e); e == nil { if e = errorHandler(dst, src, xattr, e); e == nil {
continue continue

View File

@ -1,3 +1,4 @@
//go:build openbsd || solaris
// +build openbsd solaris // +build openbsd solaris
/* /*
@ -19,10 +20,10 @@
package fs package fs
import ( import (
"errors"
"os" "os"
"syscall" "syscall"
"github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || openbsd || solaris
// +build darwin freebsd openbsd solaris // +build darwin freebsd openbsd solaris
/* /*
@ -19,12 +20,12 @@
package fs package fs
import ( import (
"fmt"
"io" "io"
"os" "os"
"syscall" "syscall"
"github.com/containerd/continuity/sysx" "github.com/containerd/continuity/sysx"
"github.com/pkg/errors"
) )
func copyFileInfo(fi os.FileInfo, name string) error { func copyFileInfo(fi os.FileInfo, name string) error {
@ -42,18 +43,18 @@ func copyFileInfo(fi os.FileInfo, name string) error {
} }
} }
if err != nil { 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 (fi.Mode() & os.ModeSymlink) != os.ModeSymlink {
if err := os.Chmod(name, fi.Mode()); err != nil { 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 { 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 return nil
@ -70,7 +71,7 @@ func copyFileContent(dst, src *os.File) error {
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error { func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
xattrKeys, err := sysx.LListxattr(src) xattrKeys, err := sysx.LListxattr(src)
if err != nil { 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 { if errorHandler != nil {
e = errorHandler(dst, src, "", e) e = errorHandler(dst, src, "", e)
} }
@ -82,7 +83,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
} }
data, err := sysx.LGetxattr(src, xattr) data, err := sysx.LGetxattr(src, xattr)
if err != nil { 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 errorHandler != nil {
if e = errorHandler(dst, src, xattr, e); e == nil { if e = errorHandler(dst, src, xattr, e); e == nil {
continue continue
@ -91,7 +92,7 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
return e return e
} }
if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil { 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 errorHandler != nil {
if e = errorHandler(dst, src, xattr, e); e == nil { if e = errorHandler(dst, src, xattr, e); e == nil {
continue continue

View File

@ -17,15 +17,15 @@
package fs package fs
import ( import (
"errors"
"fmt"
"io" "io"
"os" "os"
"github.com/pkg/errors"
) )
func copyFileInfo(fi os.FileInfo, name string) error { func copyFileInfo(fi os.FileInfo, name string) error {
if err := os.Chmod(name, fi.Mode()); err != nil { 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 // TODO: copy windows specific metadata

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
/* /*
@ -20,11 +21,11 @@ package fs
import ( import (
"bytes" "bytes"
"fmt"
"os" "os"
"syscall" "syscall"
"github.com/containerd/continuity/sysx" "github.com/containerd/continuity/sysx"
"github.com/pkg/errors"
) )
// detectDirDiff returns diff dir options if a directory could // detectDirDiff returns diff dir options if a directory could
@ -56,11 +57,11 @@ func compareSysStat(s1, s2 interface{}) (bool, error) {
func compareCapabilities(p1, p2 string) (bool, error) { func compareCapabilities(p1, p2 string) (bool, error) {
c1, err := sysx.LGetxattr(p1, "security.capability") c1, err := sysx.LGetxattr(p1, "security.capability")
if err != nil && err != sysx.ENODATA { 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") c2, err := sysx.LGetxattr(p2, "security.capability")
if err != nil && err != sysx.ENODATA { 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 return bytes.Equal(c1, c2), nil
} }

View File

@ -1,3 +1,4 @@
//go:build linux
// +build linux // +build linux
/* /*

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
/* /*

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
/* /*

View File

@ -17,11 +17,11 @@
package fstest package fstest
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/containerd/continuity" "github.com/containerd/continuity"
"github.com/pkg/errors"
) )
// CheckDirectoryEqual compares two directory paths to make sure that // CheckDirectoryEqual compares two directory paths to make sure that
@ -29,27 +29,27 @@ import (
func CheckDirectoryEqual(d1, d2 string) error { func CheckDirectoryEqual(d1, d2 string) error {
c1, err := continuity.NewContext(d1) c1, err := continuity.NewContext(d1)
if err != nil { 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) c2, err := continuity.NewContext(d2)
if err != nil { 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) m1, err := continuity.BuildManifest(c1)
if err != nil { 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) m2, err := continuity.BuildManifest(c2)
if err != nil { 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) diff := diffResourceList(m1.Resources, m2.Resources)
if diff.HasDiff() { 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 return nil

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
/* /*

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
/* /*

View File

@ -17,9 +17,8 @@
package fstest package fstest
import ( import (
"errors"
"time" "time"
"github.com/pkg/errors"
) )
// Lchtimes changes access and mod time of file without following symlink // Lchtimes changes access and mod time of file without following symlink

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
/* /*

View File

@ -19,11 +19,10 @@ package fs
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"github.com/pkg/errors"
) )
var ( var (

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || netbsd
// +build darwin freebsd netbsd // +build darwin freebsd netbsd
/* /*

View File

@ -1,3 +1,4 @@
//go:build linux || openbsd
// +build linux openbsd // +build linux openbsd
/* /*

View File

@ -9,7 +9,6 @@ require (
github.com/dustin/go-humanize v1.0.0 github.com/dustin/go-humanize v1.0.0
github.com/golang/protobuf v1.3.5 github.com/golang/protobuf v1.3.5
github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.0.0 github.com/spf13/cobra v1.0.0
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a golang.org/x/sync v0.0.0-20201207232520-09787c993a3a

View File

@ -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/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/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.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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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= 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-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-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-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/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/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= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

View File

@ -1,3 +1,4 @@
//go:build linux || darwin || freebsd || solaris
// +build linux darwin freebsd solaris // +build linux darwin freebsd solaris
/* /*

View File

@ -1,3 +1,4 @@
//go:build linux || darwin || freebsd || solaris
// +build linux darwin freebsd solaris // +build linux darwin freebsd solaris
/* /*

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || openbsd
// +build darwin freebsd openbsd // +build darwin freebsd openbsd
/* /*

View File

@ -1,3 +1,4 @@
//go:build linux || darwin
// +build linux darwin // +build linux darwin
/* /*

View File

@ -1,3 +1,4 @@
//go:build !linux && !darwin
// +build !linux,!darwin // +build !linux,!darwin
/* /*

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
/* /*

View File

@ -1,3 +1,4 @@
//go:build linux
// +build linux // +build linux
/* /*
@ -20,13 +21,14 @@ package loopback
import ( import (
"bytes" "bytes"
"errors"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"syscall" "syscall"
"github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -35,13 +37,13 @@ func New(size int64) (*Loopback, error) {
// create temporary file for the disk image // create temporary file for the disk image
file, err := ioutil.TempFile("", "containerd-test-loopback") file, err := ioutil.TempFile("", "containerd-test-loopback")
if err != nil { 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 { if err := file.Truncate(size); err != nil {
file.Close() file.Close()
os.Remove(file.Name()) 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() file.Close()
@ -52,8 +54,7 @@ func New(size int64) (*Loopback, error) {
losetup.Stderr = &stderr losetup.Stderr = &stderr
if err := losetup.Run(); err != nil { if err := losetup.Run(); err != nil {
os.Remove(file.Name()) os.Remove(file.Name())
return nil, errors.Wrapf(err, "loopback setup failed (%v): stdout=%q, stderr=%q", return nil, fmt.Errorf("loopback setup failed (%v): stdout=%q, stderr=%q: %w", losetup.Args, stdout.String(), stderr.String(), err)
losetup.Args, stdout.String(), stderr.String())
} }
deviceName := strings.TrimSpace(stdout.String()) deviceName := strings.TrimSpace(stdout.String())
@ -64,8 +65,7 @@ func New(size int64) (*Loopback, error) {
logrus.Debugf("Removing loop device %s", deviceName) logrus.Debugf("Removing loop device %s", deviceName)
losetup := exec.Command("losetup", "--detach", deviceName) losetup := exec.Command("losetup", "--detach", deviceName)
if out, err := losetup.CombinedOutput(); err != nil { if out, err := losetup.CombinedOutput(); err != nil {
return errors.Wrapf(err, "Could not remove loop device %s (%v): %q", return fmt.Errorf("Could not remove loop device %s (%v): %q: %w", deviceName, losetup.Args, string(out), err)
deviceName, losetup.Args, string(out))
} }
// remove file // remove file

View File

@ -1,3 +1,4 @@
//go:build !linux && !windows
// +build !linux,!windows // +build !linux,!windows
/* /*

2
vendor/modules.txt vendored
View File

@ -94,7 +94,7 @@ github.com/containerd/containerd/api/services/ttrpc/events/v1
github.com/containerd/containerd/api/services/version/v1 github.com/containerd/containerd/api/services/version/v1
github.com/containerd/containerd/api/types github.com/containerd/containerd/api/types
github.com/containerd/containerd/api/types/task github.com/containerd/containerd/api/types/task
# github.com/containerd/continuity v0.1.1-0.20210910181051-2e0898a8e801 # github.com/containerd/continuity v0.2.0
## explicit ## explicit
github.com/containerd/continuity github.com/containerd/continuity
github.com/containerd/continuity/devices github.com/containerd/continuity/devices