diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-06-24 11:29:13 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-06-24 13:20:59 +0200 |
commit | d697456dc90adbaf68224ed7c115b38d5855e582 (patch) | |
tree | 5fd88c48b34e7bead0028fa97e39f43f03880642 /vendor/github.com/fsouza/go-dockerclient/internal/archive | |
parent | a3211b73c62a9fcc13f09305bf629ef507b26d34 (diff) | |
download | podman-d697456dc90adbaf68224ed7c115b38d5855e582.tar.gz podman-d697456dc90adbaf68224ed7c115b38d5855e582.tar.bz2 podman-d697456dc90adbaf68224ed7c115b38d5855e582.zip |
migrate to go-modules
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/internal/archive')
4 files changed, 35 insertions, 29 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go index 7d7cf496a..f11ee0ee3 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go @@ -10,6 +10,7 @@ import ( "compress/gzip" "fmt" "io" + "log" "os" "path/filepath" "strings" @@ -18,7 +19,6 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/system" - "github.com/sirupsen/logrus" ) const ( @@ -65,31 +65,30 @@ type WhiteoutFormat int // TarOptions wraps the tar options. type TarOptions struct { - IncludeFiles []string - ExcludePatterns []string - Compression Compression - NoLchown bool - UIDMaps []idtools.IDMap - GIDMaps []idtools.IDMap - ChownOpts *idtools.Identity - IncludeSourceDir bool + IncludeFiles []string + ExcludePatterns []string + Compression Compression + UIDMaps []idtools.IDMap + GIDMaps []idtools.IDMap + ChownOpts *idtools.Identity // WhiteoutFormat is the expected on disk format for whiteout files. // This format will be converted to the standard format on pack // and from the standard format on unpack. WhiteoutFormat WhiteoutFormat // When unpacking, specifies whether overwriting a directory with a // non-directory is allowed and vice versa. - NoOverwriteDirNonDir bool // For each include when creating an archive, the included name will be // replaced with the matching name from this map. - RebaseNames map[string]string - InUserNS bool + RebaseNames map[string]string + NoLchown bool + InUserNS bool + IncludeSourceDir bool + NoOverwriteDirNonDir bool } // TarWithOptions creates an archive from the directory at `path`, only including files whose relative // paths are included in `options.IncludeFiles` (if non-nil) or not in `options.ExcludePatterns`. func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) { - // Fix the source path to work with long path names. This is a no-op // on platforms other than Windows. srcPath = fixVolumePathPrefix(srcPath) @@ -117,13 +116,13 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) defer func() { // Make sure to check the error on Close. if err := ta.TarWriter.Close(); err != nil { - logrus.Errorf("Can't close tar writer: %s", err) + log.Printf("Can't close tar writer: %s", err) } if err := compressWriter.Close(); err != nil { - logrus.Errorf("Can't close compress writer: %s", err) + log.Printf("Can't close compress writer: %s", err) } if err := pipeWriter.Close(); err != nil { - logrus.Errorf("Can't close pipe writer: %s", err) + log.Printf("Can't close pipe writer: %s", err) } }() @@ -146,7 +145,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) // directory. So, we must split the source path and use the // basename as the include. if len(options.IncludeFiles) > 0 { - logrus.Warn("Tar: Can't archive a file with includes") + log.Print("Tar: Can't archive a file with includes") } dir, base := SplitPathDirEntry(srcPath) @@ -161,12 +160,13 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) seen := make(map[string]bool) for _, include := range options.IncludeFiles { + include := include rebaseName := options.RebaseNames[include] walkRoot := getWalkRoot(srcPath, include) filepath.Walk(walkRoot, func(filePath string, f os.FileInfo, err error) error { if err != nil { - logrus.Errorf("Tar: Can't stat file %s to tar: %s", srcPath, err) + log.Printf("Tar: Can't stat file %s to tar: %s", srcPath, err) return nil } @@ -191,7 +191,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) if include != relFilePath { skip, err = pm.Matches(relFilePath) if err != nil { - logrus.Errorf("Error matching %s: %v", relFilePath, err) + log.Printf("Error matching %s: %v", relFilePath, err) return err } } @@ -247,7 +247,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) } if err := ta.addTarFile(filePath, relFilePath); err != nil { - logrus.Errorf("Can't add file %s to tar: %s", filePath, err) + log.Printf("Can't add file %s to tar: %s", filePath, err) // if pipe is broken, stop writing tar stream to it if err == io.ErrClosedPipe { return err @@ -276,8 +276,10 @@ func CompressStream(dest io.Writer, compression Compression) (io.WriteCloser, er case Bzip2, Xz: // archive/bzip2 does not support writing, and there is no xz support at all // However, this is not a problem as docker only currently generates gzipped tars + //lint:ignore ST1005 this is vendored/copied code return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension()) default: + //lint:ignore ST1005 this is vendored/copied code return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension()) } } @@ -355,13 +357,13 @@ func (ta *tarAppender) addTarFile(path, name string) error { } } - //check whether the file is overlayfs whiteout - //if yes, skip re-mapping container ID mappings. + // check whether the file is overlayfs whiteout + // if yes, skip re-mapping container ID mappings. isOverlayWhiteout := fi.Mode()&os.ModeCharDevice != 0 && hdr.Devmajor == 0 && hdr.Devminor == 0 - //handle re-mapping container ID mappings back to host ID mappings before - //writing tar headers/files. We skip whiteout files because they were written - //by the kernel and already have proper ownership relative to the host + // handle re-mapping container ID mappings back to host ID mappings before + // writing tar headers/files. We skip whiteout files because they were written + // by the kernel and already have proper ownership relative to the host if !isOverlayWhiteout && !strings.HasPrefix(filepath.Base(hdr.Name), WhiteoutPrefix) && !ta.IdentityMapping.Empty() { @@ -437,7 +439,9 @@ func (ta *tarAppender) addTarFile(path, name string) error { func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error { capability, _ := system.Lgetxattr(path, "security.capability") if capability != nil { + //lint:ignore SA1019 this is vendored/copied code hdr.Xattrs = make(map[string]string) + //lint:ignore SA1019 this is vendored/copied code hdr.Xattrs["security.capability"] = string(capability) } return nil @@ -490,7 +494,7 @@ func fillGo18FileTypeBits(mode int64, fi os.FileInfo) int64 { } // canonicalTarName provides a platform-independent and consistent posix-style -//path for files and directories to be archived regardless of the platform. +// path for files and directories to be archived regardless of the platform. func canonicalTarName(name string, isDir bool) (string, error) { name, err := CanonicalTarNameForPath(name) if err != nil { diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_linux.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_linux.go index 9e1f3f2f1..e2059e489 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_linux.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_linux.go @@ -49,7 +49,9 @@ func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os return nil, err } if len(opaque) == 1 && opaque[0] == 'y' { + //lint:ignore SA1019 this is vendored/copied code if hdr.Xattrs != nil { + //lint:ignore SA1019 this is vendored/copied code delete(hdr.Xattrs, "trusted.overlay.opaque") } diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go index 80199d513..bb6bf7145 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go @@ -42,7 +42,7 @@ func getInodeFromStat(stat interface{}) (inode uint64, err error) { s, ok := stat.(*syscall.Stat_t) if ok { - inode = uint64(s.Ino) + inode = s.Ino } return diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go index c47768e68..33c1dff03 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go @@ -24,10 +24,10 @@ func CanonicalTarNameForPath(p string) (string, error) { // in file names, it is mostly safe to replace however we must // check just in case if strings.Contains(p, "/") { + //lint:ignore ST1005 Windows should be capitalized :) return "", fmt.Errorf("Windows path contains forward slash: %s", p) } return strings.Replace(p, string(os.PathSeparator), "/", -1), nil - } // fixVolumePathPrefix does platform specific processing to ensure that if @@ -55,7 +55,7 @@ func getFileIdentity(stat interface{}) (idtools.Identity, error) { // chmodTarEntry is used to adjust the file permissions used in tar header based // on the platform the archival is done. func chmodTarEntry(perm os.FileMode) os.FileMode { - //perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.) + // perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.) permPart := perm & os.ModePerm noPermPart := perm &^ os.ModePerm // Add the x bit: make everything +x from windows |