Skip to content

Commit 14404e3

Browse files
committed
chore(tests): update vendored Docker cli code to v1.1.1
1 parent a12c6eb commit 14404e3

40 files changed

Lines changed: 522 additions & 1183 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.1.1

tests/_vendor/src/github.com/dotcloud/docker/api/client/commands.go

Lines changed: 87 additions & 55 deletions
Large diffs are not rendered by default.

tests/_vendor/src/github.com/dotcloud/docker/api/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const (
14-
APIVERSION version.Version = "1.12"
14+
APIVERSION version.Version = "1.13"
1515
DEFAULTHTTPHOST = "127.0.0.1"
1616
DEFAULTUNIXSOCKET = "/var/run/docker.sock"
1717
)

tests/_vendor/src/github.com/dotcloud/docker/archive/archive.go

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type (
2727
Compression int
2828
TarOptions struct {
2929
Includes []string
30+
Excludes []string
3031
Compression Compression
3132
NoLchown bool
3233
}
@@ -43,6 +44,16 @@ const (
4344
Xz
4445
)
4546

47+
func IsArchive(header []byte) bool {
48+
compression := DetectCompression(header)
49+
if compression != Uncompressed {
50+
return true
51+
}
52+
r := tar.NewReader(bytes.NewBuffer(header))
53+
_, err := r.Next()
54+
return err == nil
55+
}
56+
4657
func DetectCompression(source []byte) Compression {
4758
for compression, m := range map[Compression][]byte{
4859
Bzip2: {0x42, 0x5A, 0x68},
@@ -276,7 +287,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
276287
// Tar creates an archive from the directory at `path`, and returns it as a
277288
// stream of bytes.
278289
func Tar(path string, compression Compression) (io.ReadCloser, error) {
279-
return TarFilter(path, &TarOptions{Compression: compression})
290+
return TarWithOptions(path, &TarOptions{Compression: compression})
280291
}
281292

282293
func escapeName(name string) string {
@@ -295,12 +306,9 @@ func escapeName(name string) string {
295306
return string(escaped)
296307
}
297308

298-
// TarFilter creates an archive from the directory at `srcPath` with `options`, and returns it as a
299-
// stream of bytes.
300-
//
301-
// Files are included according to `options.Includes`, default to including all files.
302-
// Stream is compressed according to `options.Compression', default to Uncompressed.
303-
func TarFilter(srcPath string, options *TarOptions) (io.ReadCloser, error) {
309+
// TarWithOptions creates an archive from the directory at `path`, only including files whose relative
310+
// paths are included in `options.Includes` (if non-nil) or not in `options.Excludes`.
311+
func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) {
304312
pipeReader, pipeWriter := io.Pipe()
305313

306314
compressWriter, err := CompressStream(pipeWriter, options.Compression)
@@ -332,6 +340,21 @@ func TarFilter(srcPath string, options *TarOptions) (io.ReadCloser, error) {
332340
return nil
333341
}
334342

343+
for _, exclude := range options.Excludes {
344+
matched, err := filepath.Match(exclude, relFilePath)
345+
if err != nil {
346+
utils.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude)
347+
return err
348+
}
349+
if matched {
350+
utils.Debugf("Skipping excluded path: %s", relFilePath)
351+
if f.IsDir() {
352+
return filepath.SkipDir
353+
}
354+
return nil
355+
}
356+
}
357+
335358
if err := addTarFile(filePath, relFilePath, tw); err != nil {
336359
utils.Debugf("Can't add file %s to tar: %s\n", srcPath, err)
337360
}
@@ -443,7 +466,7 @@ func Untar(archive io.Reader, dest string, options *TarOptions) error {
443466
// TarUntar aborts and returns the error.
444467
func TarUntar(src string, dst string) error {
445468
utils.Debugf("TarUntar(%s %s)", src, dst)
446-
archive, err := TarFilter(src, &TarOptions{Compression: Uncompressed})
469+
archive, err := TarWithOptions(src, &TarOptions{Compression: Uncompressed})
447470
if err != nil {
448471
return err
449472
}

tests/_vendor/src/github.com/dotcloud/docker/engine/env.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ func (env *Env) SetAuto(k string, v interface{}) {
199199
}
200200
}
201201

202+
func changeFloats(v interface{}) interface{} {
203+
switch v := v.(type) {
204+
case float64:
205+
return int(v)
206+
case map[string]interface{}:
207+
for key, val := range v {
208+
v[key] = changeFloats(val)
209+
}
210+
case []interface{}:
211+
for idx, val := range v {
212+
v[idx] = changeFloats(val)
213+
}
214+
}
215+
return v
216+
}
217+
202218
func (env *Env) Encode(dst io.Writer) error {
203219
m := make(map[string]interface{})
204220
for k, v := range env.Map() {
@@ -207,10 +223,7 @@ func (env *Env) Encode(dst io.Writer) error {
207223
// FIXME: we fix-convert float values to int, because
208224
// encoding/json decodes integers to float64, but cannot encode them back.
209225
// (See http://golang.org/src/pkg/encoding/json/decode.go#L46)
210-
if fval, isFloat := val.(float64); isFloat {
211-
val = int(fval)
212-
}
213-
m[k] = val
226+
m[k] = changeFloats(val)
214227
} else {
215228
m[k] = v
216229
}

tests/_vendor/src/github.com/dotcloud/docker/engine/http.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/_vendor/src/github.com/dotcloud/docker/nat/sort.go

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2014 The Docker & Go Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following disclaimer
11+
in the documentation and/or other materials provided with the
12+
distribution.
13+
* Neither the name of Google Inc. nor the names of its
14+
contributors may be used to endorse or promote products derived from
15+
this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

tests/_vendor/src/github.com/dotcloud/docker/pkg/mflag/example/example.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/_vendor/src/github.com/dotcloud/docker/pkg/mflag/flag.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,10 @@ type flagSlice []string
305305

306306
func (p flagSlice) Len() int { return len(p) }
307307
func (p flagSlice) Less(i, j int) bool {
308-
pi, pj := strings.ToLower(p[i]), strings.ToLower(p[j])
309-
if pi[0] == '-' {
310-
pi = pi[1:]
311-
}
312-
if pj[0] == '-' {
313-
pj = pj[1:]
308+
pi, pj := strings.TrimPrefix(p[i], "-"), strings.TrimPrefix(p[j], "-")
309+
lpi, lpj := strings.ToLower(pi), strings.ToLower(pj)
310+
if lpi != lpj {
311+
return lpi < lpj
314312
}
315313
return pi < pj
316314
}
@@ -443,8 +441,6 @@ func (f *FlagSet) PrintDefaults() {
443441
}
444442
fmt.Fprintln(writer, "\t", line)
445443
}
446-
// start := fmt.Sprintf(format, strings.Join(names, ", -"), flag.DefValue)
447-
// fmt.Fprintln(f.out(), start, strings.Replace(flag.Usage, "\n", "\n"+strings.Repeat(" ", len(start)+1), -1))
448444
}
449445
})
450446
writer.Flush()
@@ -833,14 +829,12 @@ func (f *FlagSet) parseOne() (bool, string, error) {
833829
f.args = f.args[1:]
834830
has_value := false
835831
value := ""
836-
for i := 1; i < len(name); i++ { // equals cannot be first
837-
if name[i] == '=' {
838-
value = trimQuotes(name[i+1:])
839-
has_value = true
840-
name = name[0:i]
841-
break
842-
}
832+
if i := strings.Index(name, "="); i != -1 {
833+
value = trimQuotes(name[i+1:])
834+
has_value = true
835+
name = name[:i]
843836
}
837+
844838
m := f.formal
845839
flag, alreadythere := m[name] // BUG
846840
if !alreadythere {

0 commit comments

Comments
 (0)