bump(docker/docker/pkg/parsers):ed6685369740035b0af9675bf9add52d0af7657b

Add docker/docker/pkg/parsers and bump entire set of docker/docker/...
dependencies.
pull/6/head
Andy Goldstein 2015-03-16 20:50:51 -04:00
parent 7e42fc86fd
commit b7c177944e
21 changed files with 275 additions and 65 deletions

49
Godeps/Godeps.json generated
View File

@ -88,58 +88,63 @@
},
{
"ImportPath": "github.com/docker/docker/pkg/archive",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/fileutils",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/ioutils",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/mount",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/parsers",
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/pools",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/promise",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/symlink",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/system",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/term",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/pkg/units",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar",
"Comment": "v1.4.1-656-g2115131",
"Rev": "211513156dc1ace48e630b4bf4ea0fcfdc8d9abf"
"Comment": "v1.4.1-1714-ged66853",
"Rev": "ed6685369740035b0af9675bf9add52d0af7657b"
},
{
"ImportPath": "github.com/docker/libcontainer",

View File

@ -1,2 +0,0 @@
Cristian Staretu <cristian.staretu@gmail.com> (@unclejack)
Tibor Vass <teabee89@gmail.com> (@tiborvass)

View File

@ -101,7 +101,6 @@ func DecompressStream(archive io.Reader) (io.ReadCloser, error) {
if err != nil {
return nil, err
}
log.Debugf("[tar autodetect] n: %v", bs)
compression := DetectCompression(bs)
switch compression {
@ -173,6 +172,21 @@ type tarAppender struct {
SeenFiles map[uint64]string
}
// canonicalTarName provides a platform-independent and consistent posix-style
//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 {
return "", err
}
// suffix with '/' for directories
if isDir && !strings.HasSuffix(name, "/") {
name += "/"
}
return name, nil
}
func (ta *tarAppender) addTarFile(path, name string) error {
fi, err := os.Lstat(path)
if err != nil {
@ -190,11 +204,12 @@ func (ta *tarAppender) addTarFile(path, name string) error {
if err != nil {
return err
}
hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode)))
if fi.IsDir() && !strings.HasSuffix(name, "/") {
name = name + "/"
name, err = canonicalTarName(name, fi.IsDir())
if err != nil {
return fmt.Errorf("tar: cannot canonicalize path: %v", err)
}
hdr.Name = name
nlink, inode, err := setHeaderForSpecialDevice(hdr, ta, name, fi.Sys())
@ -459,7 +474,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
}
if err := ta.addTarFile(filePath, relFilePath); err != nil {
log.Debugf("Can't add file %s to tar: %s", srcPath, err)
log.Debugf("Can't add file %s to tar: %s", filePath, err)
}
return nil
})
@ -526,7 +541,7 @@ loop:
if err != nil {
return err
}
if strings.HasPrefix(rel, "..") {
if strings.HasPrefix(rel, "../") {
return breakoutError(fmt.Errorf("%q is outside of %q", hdr.Name, dest))
}
@ -682,6 +697,8 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) {
return err
}
hdr.Name = filepath.Base(dst)
hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode)))
tw := tar.NewWriter(w)
defer tw.Close()
if err := tw.WriteHeader(hdr); err != nil {

View File

@ -4,11 +4,26 @@ package archive
import (
"errors"
"os"
"syscall"
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
)
// canonicalTarNameForPath returns platform-specific filepath
// to canonical posix-style path for tar archival. p is relative
// path.
func CanonicalTarNameForPath(p string) (string, error) {
return p, nil // already unix-style
}
// 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 {
return perm // noop for unix as golang APIs provide perm bits correctly
}
func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) {
s, ok := stat.(*syscall.Stat_t)

View File

@ -3,9 +3,39 @@
package archive
import (
"fmt"
"os"
"strings"
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
)
// canonicalTarNameForPath returns platform-specific filepath
// to canonical posix-style path for tar archival. p is relative
// path.
func CanonicalTarNameForPath(p string) (string, error) {
// windows: convert windows style relative path with backslashes
// into forward slashes. since windows does not allow '/' or '\'
// in file names, it is mostly safe to replace however we must
// check just in case
if strings.Contains(p, "/") {
return "", fmt.Errorf("windows path contains forward slash: %s", p)
}
return strings.Replace(p, string(os.PathSeparator), "/", -1), nil
}
// 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 {
// Clear r/w on grp/others: no precise equivalen of group/others on NTFS.
perm &= 0711
// Add the x bit: make everything +x from windows
perm |= 0100
return perm
}
func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) {
// do nothing. no notion of Rdev, Inode, Nlink in stat on Windows
return

View File

@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"sort"
"strings"
"syscall"
"time"
@ -43,6 +44,13 @@ func (change *Change) String() string {
return fmt.Sprintf("%s %s", kind, change.Path)
}
// for sort.Sort
type changesByPath []Change
func (c changesByPath) Less(i, j int) bool { return c[i].Path < c[j].Path }
func (c changesByPath) Len() int { return len(c) }
func (c changesByPath) Swap(i, j int) { c[j], c[i] = c[i], c[j] }
// Gnu tar and the go tar writer don't have sub-second mtime
// precision, which is problematic when we apply changes via tar
// files, we handle this by comparing for exact times, *or* same
@ -135,7 +143,7 @@ func Changes(layers []string, rw string) ([]Change, error) {
type FileInfo struct {
parent *FileInfo
name string
stat *system.Stat
stat *system.Stat_t
children map[string]*FileInfo
capability []byte
added bool
@ -373,6 +381,8 @@ func ExportChanges(dir string, changes []Change) (Archive, error) {
// this buffer is needed for the duration of this piped stream
defer pools.BufioWriter32KPool.Put(ta.Buffer)
sort.Sort(changesByPath(changes))
// In general we log errors here but ignore them because
// during e.g. a diff operation the container can continue
// mutating the filesystem and we can see transient errors

View File

@ -25,13 +25,6 @@ func copyDir(src, dst string) error {
return nil
}
// Helper to sort []Change by path
type byPath struct{ changes []Change }
func (b byPath) Less(i, j int) bool { return b.changes[i].Path < b.changes[j].Path }
func (b byPath) Len() int { return len(b.changes) }
func (b byPath) Swap(i, j int) { b.changes[i], b.changes[j] = b.changes[j], b.changes[i] }
type FileType uint32
const (
@ -220,7 +213,7 @@ func TestChangesDirsMutated(t *testing.T) {
t.Fatal(err)
}
sort.Sort(byPath{changes})
sort.Sort(changesByPath(changes))
expectedChanges := []Change{
{"/dir1", ChangeDelete},

View File

@ -81,7 +81,7 @@ func UnpackLayer(dest string, layer ArchiveReader) (size int64, err error) {
if err != nil {
return 0, err
}
if strings.HasPrefix(rel, "..") {
if strings.HasPrefix(rel, "../") {
return 0, breakoutError(fmt.Errorf("%q is outside of %q", hdr.Name, dest))
}
base := filepath.Base(path)

View File

@ -1 +0,0 @@
Michael Crosby <michael@crosbymichael.com> (@crosbymichael)

View File

@ -9,7 +9,7 @@ import (
"testing"
)
// nothing is propogated in or out
// nothing is propagated in or out
func TestSubtreePrivate(t *testing.T) {
tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {

View File

@ -0,0 +1,137 @@
package parsers
import (
"fmt"
"strconv"
"strings"
)
// FIXME: Change this not to receive default value as parameter
func ParseHost(defaultTCPAddr, defaultUnixAddr, addr string) (string, error) {
addr = strings.TrimSpace(addr)
if addr == "" {
addr = fmt.Sprintf("unix://%s", defaultUnixAddr)
}
addrParts := strings.Split(addr, "://")
if len(addrParts) == 1 {
addrParts = []string{"tcp", addrParts[0]}
}
switch addrParts[0] {
case "tcp":
return ParseTCPAddr(addrParts[1], defaultTCPAddr)
case "unix":
return ParseUnixAddr(addrParts[1], defaultUnixAddr)
case "fd":
return addr, nil
default:
return "", fmt.Errorf("Invalid bind address format: %s", addr)
}
}
func ParseUnixAddr(addr string, defaultAddr string) (string, error) {
addr = strings.TrimPrefix(addr, "unix://")
if strings.Contains(addr, "://") {
return "", fmt.Errorf("Invalid proto, expected unix: %s", addr)
}
if addr == "" {
addr = defaultAddr
}
return fmt.Sprintf("unix://%s", addr), nil
}
func ParseTCPAddr(addr string, defaultAddr string) (string, error) {
addr = strings.TrimPrefix(addr, "tcp://")
if strings.Contains(addr, "://") || addr == "" {
return "", fmt.Errorf("Invalid proto, expected tcp: %s", addr)
}
hostParts := strings.Split(addr, ":")
if len(hostParts) != 2 {
return "", fmt.Errorf("Invalid bind address format: %s", addr)
}
host := hostParts[0]
if host == "" {
host = defaultAddr
}
p, err := strconv.Atoi(hostParts[1])
if err != nil && p == 0 {
return "", fmt.Errorf("Invalid bind address format: %s", addr)
}
return fmt.Sprintf("tcp://%s:%d", host, p), nil
}
// Get a repos name and returns the right reposName + tag|digest
// The tag can be confusing because of a port in a repository name.
// Ex: localhost.localdomain:5000/samalba/hipache:latest
// Digest ex: localhost:5000/foo/bar@sha256:bc8813ea7b3603864987522f02a76101c17ad122e1c46d790efc0fca78ca7bfb
func ParseRepositoryTag(repos string) (string, string) {
n := strings.Index(repos, "@")
if n >= 0 {
parts := strings.Split(repos, "@")
return parts[0], parts[1]
}
n = strings.LastIndex(repos, ":")
if n < 0 {
return repos, ""
}
if tag := repos[n+1:]; !strings.Contains(tag, "/") {
return repos[:n], tag
}
return repos, ""
}
func PartParser(template, data string) (map[string]string, error) {
// ip:public:private
var (
templateParts = strings.Split(template, ":")
parts = strings.Split(data, ":")
out = make(map[string]string, len(templateParts))
)
if len(parts) != len(templateParts) {
return nil, fmt.Errorf("Invalid format to parse. %s should match template %s", data, template)
}
for i, t := range templateParts {
value := ""
if len(parts) > i {
value = parts[i]
}
out[t] = value
}
return out, nil
}
func ParseKeyValueOpt(opt string) (string, string, error) {
parts := strings.SplitN(opt, "=", 2)
if len(parts) != 2 {
return "", "", fmt.Errorf("Unable to parse key/value option: %s", opt)
}
return strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1]), nil
}
func ParsePortRange(ports string) (uint64, uint64, error) {
if ports == "" {
return 0, 0, fmt.Errorf("Empty string specified for ports.")
}
if !strings.Contains(ports, "-") {
start, err := strconv.ParseUint(ports, 10, 16)
end := start
return start, end, err
}
parts := strings.Split(ports, "-")
start, err := strconv.ParseUint(parts[0], 10, 16)
if err != nil {
return 0, 0, err
}
end, err := strconv.ParseUint(parts[1], 10, 16)
if err != nil {
return 0, 0, err
}
if end < start {
return 0, 0, fmt.Errorf("Invalid range specified for the Port: %s", ports)
}
return start, end, nil
}

View File

@ -1,3 +0,0 @@
Tibor Vass <teabee89@gmail.com> (@tiborvass)
Cristian Staretu <cristian.staretu@gmail.com> (@unclejack)
Tianon Gravi <admwiggin@gmail.com> (@tianon)

View File

@ -1,2 +0,0 @@
Michael Crosby <michael@crosbymichael.com> (@crosbymichael)
Victor Vieux <vieux@docker.com> (@vieux)

View File

@ -6,7 +6,7 @@ import (
"syscall"
)
func Lstat(path string) (*Stat, error) {
func Lstat(path string) (*Stat_t, error) {
s := &syscall.Stat_t{}
err := syscall.Lstat(path, s)
if err != nil {

View File

@ -2,7 +2,7 @@
package system
func Lstat(path string) (*Stat, error) {
func Lstat(path string) (*Stat_t, error) {
// should not be called on cli code path
return nil, ErrNotSupportedPlatform
}

View File

@ -4,7 +4,7 @@ import (
"syscall"
)
type Stat struct {
type Stat_t struct {
mode uint32
uid uint32
gid uint32
@ -13,30 +13,30 @@ type Stat struct {
mtim syscall.Timespec
}
func (s Stat) Mode() uint32 {
func (s Stat_t) Mode() uint32 {
return s.mode
}
func (s Stat) Uid() uint32 {
func (s Stat_t) Uid() uint32 {
return s.uid
}
func (s Stat) Gid() uint32 {
func (s Stat_t) Gid() uint32 {
return s.gid
}
func (s Stat) Rdev() uint64 {
func (s Stat_t) Rdev() uint64 {
return s.rdev
}
func (s Stat) Size() int64 {
func (s Stat_t) Size() int64 {
return s.size
}
func (s Stat) Mtim() syscall.Timespec {
func (s Stat_t) Mtim() syscall.Timespec {
return s.mtim
}
func (s Stat) GetLastModification() syscall.Timespec {
func (s Stat_t) GetLastModification() syscall.Timespec {
return s.Mtim()
}

View File

@ -4,11 +4,20 @@ import (
"syscall"
)
func fromStatT(s *syscall.Stat_t) (*Stat, error) {
return &Stat{size: s.Size,
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
return &Stat_t{size: s.Size,
mode: s.Mode,
uid: s.Uid,
gid: s.Gid,
rdev: s.Rdev,
mtim: s.Mtim}, nil
}
func Stat(path string) (*Stat_t, error) {
s := &syscall.Stat_t{}
err := syscall.Stat(path, s)
if err != nil {
return nil, err
}
return fromStatT(s)
}

View File

@ -6,8 +6,8 @@ import (
"syscall"
)
func fromStatT(s *syscall.Stat_t) (*Stat, error) {
return &Stat{size: s.Size,
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
return &Stat_t{size: s.Size,
mode: uint32(s.Mode),
uid: s.Uid,
gid: s.Gid,

View File

@ -7,6 +7,11 @@ import (
"syscall"
)
func fromStatT(s *syscall.Win32FileAttributeData) (*Stat, error) {
func fromStatT(s *syscall.Win32FileAttributeData) (*Stat_t, error) {
return nil, errors.New("fromStatT should not be called on windows path")
}
func Stat(path string) (*Stat_t, error) {
// should not be called on cli code path
return nil, ErrNotSupportedPlatform
}

View File

@ -1 +0,0 @@
Solomon Hykes <solomon@docker.com> (@shykes)

View File

@ -1,2 +0,0 @@
Victor Vieux <vieux@docker.com> (@vieux)
Jessie Frazelle <jess@docker.com> (@jfrazelle)