summaryrefslogtreecommitdiff
path: root/vendor/github.com/fsouza/go-dockerclient/internal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/internal')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go56
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_linux.go2
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go2
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go4
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/jsonmessage/jsonmessage.go125
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/term/term.go2
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/internal/term/winsize.go2
7 files changed, 130 insertions, 63 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
diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/jsonmessage/jsonmessage.go b/vendor/github.com/fsouza/go-dockerclient/internal/jsonmessage/jsonmessage.go
index 71b3395ce..99a32ae05 100644
--- a/vendor/github.com/fsouza/go-dockerclient/internal/jsonmessage/jsonmessage.go
+++ b/vendor/github.com/fsouza/go-dockerclient/internal/jsonmessage/jsonmessage.go
@@ -12,9 +12,9 @@ import (
"strings"
"time"
- "github.com/Nvveen/Gotty"
- "github.com/docker/go-units"
+ units "github.com/docker/go-units"
"github.com/fsouza/go-dockerclient/internal/term"
+ gotty "github.com/ijc/Gotty"
)
// RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to
@@ -144,13 +144,13 @@ type JSONMessage struct {
Stream string `json:"stream,omitempty"`
Status string `json:"status,omitempty"`
Progress *JSONProgress `json:"progressDetail,omitempty"`
- ProgressMessage string `json:"progress,omitempty"` //deprecated
+ ProgressMessage string `json:"progress,omitempty"` // deprecated
ID string `json:"id,omitempty"`
From string `json:"from,omitempty"`
Time int64 `json:"time,omitempty"`
TimeNano int64 `json:"timeNano,omitempty"`
Error *JSONError `json:"errorDetail,omitempty"`
- ErrorMessage string `json:"error,omitempty"` //deprecated
+ ErrorMessage string `json:"error,omitempty"` // deprecated
// Aux contains out-of-band data, such as digests for push signing and image id after building.
Aux *json.RawMessage `json:"aux,omitempty"`
}
@@ -166,43 +166,72 @@ func (ti *noTermInfo) Parse(attr string, params ...interface{}) (string, error)
return "", fmt.Errorf("noTermInfo")
}
-func clearLine(out io.Writer, ti termInfo) {
+func clearLine(out io.Writer, ti termInfo) error {
// el2 (clear whole line) is not exposed by terminfo.
// First clear line from beginning to cursor
if attr, err := ti.Parse("el1"); err == nil {
- fmt.Fprintf(out, "%s", attr)
+ _, err = fmt.Fprintf(out, "%s", attr)
+ if err != nil {
+ return err
+ }
} else {
- fmt.Fprintf(out, "\x1b[1K")
+ _, err := fmt.Fprintf(out, "\x1b[1K")
+ if err != nil {
+ return err
+ }
}
// Then clear line from cursor to end
if attr, err := ti.Parse("el"); err == nil {
- fmt.Fprintf(out, "%s", attr)
+ _, err = fmt.Fprintf(out, "%s", attr)
+ if err != nil {
+ return err
+ }
} else {
- fmt.Fprintf(out, "\x1b[K")
+ _, err := fmt.Fprintf(out, "\x1b[K")
+ if err != nil {
+ return err
+ }
}
+
+ return nil
}
-func cursorUp(out io.Writer, ti termInfo, l int) {
+func cursorUp(out io.Writer, ti termInfo, l int) error {
if l == 0 { // Should never be the case, but be tolerant
- return
+ return nil
}
if attr, err := ti.Parse("cuu", l); err == nil {
- fmt.Fprintf(out, "%s", attr)
+ _, err = fmt.Fprintf(out, "%s", attr)
+ if err != nil {
+ return err
+ }
} else {
- fmt.Fprintf(out, "\x1b[%dA", l)
+ _, err := fmt.Fprintf(out, "\x1b[%dA", l)
+ if err != nil {
+ return err
+ }
}
+ return nil
}
-func cursorDown(out io.Writer, ti termInfo, l int) {
+func cursorDown(out io.Writer, ti termInfo, l int) error {
if l == 0 { // Should never be the case, but be tolerant
- return
+ return nil
}
if attr, err := ti.Parse("cud", l); err == nil {
- fmt.Fprintf(out, "%s", attr)
+ _, err = fmt.Fprintf(out, "%s", attr)
+ if err != nil {
+ return err
+ }
} else {
- fmt.Fprintf(out, "\x1b[%dB", l)
+ _, err := fmt.Fprintf(out, "\x1b[%dB", l)
+ if err != nil {
+ return err
+ }
}
+
+ return nil
}
// Display displays the JSONMessage to `out`. `termInfo` is non-nil if `out`
@@ -219,29 +248,56 @@ func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error {
if termInfo != nil && jm.Stream == "" && jm.Progress != nil {
clearLine(out, termInfo)
endl = "\r"
- fmt.Fprintf(out, endl)
- } else if jm.Progress != nil && jm.Progress.String() != "" { //disable progressbar in non-terminal
+ _, err := fmt.Fprint(out, endl)
+ if err != nil {
+ return err
+ }
+ } else if jm.Progress != nil && jm.Progress.String() != "" { // disable progressbar in non-terminal
return nil
}
if jm.TimeNano != 0 {
- fmt.Fprintf(out, "%s ", time.Unix(0, jm.TimeNano).Format(RFC3339NanoFixed))
+ _, err := fmt.Fprintf(out, "%s ", time.Unix(0, jm.TimeNano).Format(RFC3339NanoFixed))
+ if err != nil {
+ return err
+ }
} else if jm.Time != 0 {
- fmt.Fprintf(out, "%s ", time.Unix(jm.Time, 0).Format(RFC3339NanoFixed))
+ _, err := fmt.Fprintf(out, "%s ", time.Unix(jm.Time, 0).Format(RFC3339NanoFixed))
+ if err != nil {
+ return err
+ }
}
if jm.ID != "" {
- fmt.Fprintf(out, "%s: ", jm.ID)
+ _, err := fmt.Fprintf(out, "%s: ", jm.ID)
+ if err != nil {
+ return err
+ }
}
if jm.From != "" {
- fmt.Fprintf(out, "(from %s) ", jm.From)
+ _, err := fmt.Fprintf(out, "(from %s) ", jm.From)
+ if err != nil {
+ return err
+ }
}
if jm.Progress != nil && termInfo != nil {
- fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
- } else if jm.ProgressMessage != "" { //deprecated
- fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
+ _, err := fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
+ if err != nil {
+ return err
+ }
+ } else if jm.ProgressMessage != "" { // deprecated
+ _, err := fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
+ if err != nil {
+ return err
+ }
} else if jm.Stream != "" {
- fmt.Fprintf(out, "%s%s", jm.Stream, endl)
+ _, err := fmt.Fprintf(out, "%s%s", jm.Stream, endl)
+ if err != nil {
+ return err
+ }
} else {
- fmt.Fprintf(out, "%s%s\n", jm.Status, endl)
+ _, err := fmt.Fprintf(out, "%s%s\n", jm.Status, endl)
+ if err != nil {
+ return err
+ }
}
return nil
}
@@ -301,12 +357,17 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
line = len(ids)
ids[jm.ID] = line
if termInfo != nil {
- fmt.Fprintf(out, "\n")
+ _, err := fmt.Fprintf(out, "\n")
+ if err != nil {
+ return err
+ }
}
}
diff = len(ids) - line
if termInfo != nil {
- cursorUp(out, termInfo, diff)
+ if err := cursorUp(out, termInfo, diff); err != nil {
+ return err
+ }
}
} else {
// When outputting something that isn't progress
@@ -318,7 +379,9 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
}
err := jm.Display(out, termInfo)
if jm.ID != "" && termInfo != nil {
- cursorDown(out, termInfo, diff)
+ if err := cursorDown(out, termInfo, diff); err != nil {
+ return err
+ }
}
if err != nil {
return err
diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/term/term.go b/vendor/github.com/fsouza/go-dockerclient/internal/term/term.go
index af06911d8..7d3c11358 100644
--- a/vendor/github.com/fsouza/go-dockerclient/internal/term/term.go
+++ b/vendor/github.com/fsouza/go-dockerclient/internal/term/term.go
@@ -8,6 +8,4 @@ package term
type Winsize struct {
Height uint16
Width uint16
- x uint16
- y uint16
}
diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/term/winsize.go b/vendor/github.com/fsouza/go-dockerclient/internal/term/winsize.go
index 2a9964a0d..92a80a308 100644
--- a/vendor/github.com/fsouza/go-dockerclient/internal/term/winsize.go
+++ b/vendor/github.com/fsouza/go-dockerclient/internal/term/winsize.go
@@ -11,6 +11,6 @@ import "golang.org/x/sys/unix"
// GetWinsize returns the window size based on the specified file descriptor.
func GetWinsize(fd uintptr) (*Winsize, error) {
uws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
- ws := &Winsize{Height: uws.Row, Width: uws.Col, x: uws.Xpixel, y: uws.Ypixel}
+ ws := &Winsize{Height: uws.Row, Width: uws.Col}
return ws, err
}