瀏覽代碼

Merge pull request #8302 from rafecolton/move_archive_package_to_pkg

Move archive package to pkg
unclejack 10 年之前
父節點
當前提交
4424d15f99

+ 5 - 4
api/client/commands.go

@@ -23,16 +23,17 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/nat"
 	"github.com/docker/docker/nat"
 	"github.com/docker/docker/opts"
 	"github.com/docker/docker/opts"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	flag "github.com/docker/docker/pkg/mflag"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers/filters"
 	"github.com/docker/docker/pkg/parsers/filters"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/timeutils"
 	"github.com/docker/docker/pkg/timeutils"
@@ -648,7 +649,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
 		v.Set("stdout", "1")
 		v.Set("stdout", "1")
 		v.Set("stderr", "1")
 		v.Set("stderr", "1")
 
 
-		cErr = utils.Go(func() error {
+		cErr = promise.Go(func() error {
 			return cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), tty, in, cli.out, cli.err, nil, nil)
 			return cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), tty, in, cli.out, cli.err, nil, nil)
 		})
 		})
 	}
 	}
@@ -2220,7 +2221,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
 			}
 			}
 		}
 		}
 
 
-		errCh = utils.Go(func() error {
+		errCh = promise.Go(func() error {
 			return cli.hijack("POST", "/containers/"+runResult.Get("Id")+"/attach?"+v.Encode(), config.Tty, in, out, stderr, hijacked, nil)
 			return cli.hijack("POST", "/containers/"+runResult.Get("Id")+"/attach?"+v.Encode(), config.Tty, in, out, stderr, hijacked, nil)
 		})
 		})
 	} else {
 	} else {
@@ -2477,7 +2478,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
 			stderr = cli.err
 			stderr = cli.err
 		}
 		}
 	}
 	}
-	errCh = utils.Go(func() error {
+	errCh = promise.Go(func() error {
 		return cli.hijack("POST", "/exec/"+execID+"/start", execConfig.Tty, in, out, stderr, hijacked, execConfig)
 		return cli.hijack("POST", "/exec/"+execID+"/start", execConfig.Tty, in, out, stderr, hijacked, execConfig)
 	})
 	})
 
 

+ 3 - 3
api/client/hijack.go

@@ -14,9 +14,9 @@ import (
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/term"
-	"github.com/docker/docker/utils"
 )
 )
 
 
 func (cli *DockerCli) dial() (net.Conn, error) {
 func (cli *DockerCli) dial() (net.Conn, error) {
@@ -78,7 +78,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
 	}
 	}
 
 
 	if stdout != nil || stderr != nil {
 	if stdout != nil || stderr != nil {
-		receiveStdout = utils.Go(func() (err error) {
+		receiveStdout = promise.Go(func() (err error) {
 			defer func() {
 			defer func() {
 				if in != nil {
 				if in != nil {
 					if setRawTerminal && cli.isTerminalIn {
 					if setRawTerminal && cli.isTerminalIn {
@@ -104,7 +104,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
 		})
 		})
 	}
 	}
 
 
-	sendStdin := utils.Go(func() error {
+	sendStdin := promise.Go(func() error {
 		if in != nil {
 		if in != nil {
 			io.Copy(rwc, in)
 			io.Copy(rwc, in)
 			log.Debugf("[hijack] End of stdin")
 			log.Debugf("[hijack] End of stdin")

+ 0 - 3
archive/README.md

@@ -1,3 +0,0 @@
-This code provides helper functions for dealing with archive files.
-
-**TODO**: Move this to either `pkg` or (if not possible) to `utils`.

+ 3 - 2
builder/internals.go

@@ -18,11 +18,12 @@ import (
 	"syscall"
 	"syscall"
 	"time"
 	"time"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon"
 	"github.com/docker/docker/daemon"
 	imagepkg "github.com/docker/docker/image"
 	imagepkg "github.com/docker/docker/image"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/tarsum"
 	"github.com/docker/docker/pkg/tarsum"
@@ -516,7 +517,7 @@ func (b *Builder) create() (*daemon.Container, error) {
 func (b *Builder) run(c *daemon.Container) error {
 func (b *Builder) run(c *daemon.Container) error {
 	var errCh chan error
 	var errCh chan error
 	if b.Verbose {
 	if b.Verbose {
-		errCh = utils.Go(func() error {
+		errCh = promise.Go(func() error {
 			// FIXME: call the 'attach' job so that daemon.Attach can be made private
 			// FIXME: call the 'attach' job so that daemon.Attach can be made private
 			//
 			//
 			// FIXME (LK4D4): Also, maybe makes sense to call "logs" job, it is like attach
 			// FIXME (LK4D4): Also, maybe makes sense to call "logs" job, it is like attach

+ 1 - 1
builder/job.go

@@ -7,9 +7,9 @@ import (
 	"os/exec"
 	"os/exec"
 	"strings"
 	"strings"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon"
 	"github.com/docker/docker/daemon"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"

+ 2 - 1
daemon/attach.go

@@ -10,6 +10,7 @@ import (
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/jsonlog"
 	"github.com/docker/docker/pkg/jsonlog"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 )
 )
 
 
@@ -246,7 +247,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t
 		}()
 		}()
 	}
 	}
 
 
-	return utils.Go(func() error {
+	return promise.Go(func() error {
 		defer func() {
 		defer func() {
 			if cStdout != nil {
 			if cStdout != nil {
 				cStdout.Close()
 				cStdout.Close()

+ 3 - 2
daemon/container.go

@@ -16,17 +16,18 @@ import (
 	"github.com/docker/libcontainer/devices"
 	"github.com/docker/libcontainer/devices"
 	"github.com/docker/libcontainer/label"
 	"github.com/docker/libcontainer/label"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/links"
 	"github.com/docker/docker/links"
 	"github.com/docker/docker/nat"
 	"github.com/docker/docker/nat"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/broadcastwriter"
 	"github.com/docker/docker/pkg/broadcastwriter"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/networkfs/etchosts"
 	"github.com/docker/docker/pkg/networkfs/etchosts"
 	"github.com/docker/docker/pkg/networkfs/resolvconf"
 	"github.com/docker/docker/pkg/networkfs/resolvconf"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
@@ -1119,7 +1120,7 @@ func (container *Container) waitForStart() error {
 	// process or until the process is running in the container
 	// process or until the process is running in the container
 	select {
 	select {
 	case <-container.monitor.startSignal:
 	case <-container.monitor.startSignal:
-	case err := <-utils.Go(container.monitor.Start):
+	case err := <-promise.Go(container.monitor.Start):
 		return err
 		return err
 	}
 	}
 
 

+ 1 - 1
daemon/daemon.go

@@ -15,7 +15,6 @@ import (
 
 
 	"github.com/docker/libcontainer/label"
 	"github.com/docker/libcontainer/label"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver/execdrivers"
 	"github.com/docker/docker/daemon/execdriver/execdrivers"
 	"github.com/docker/docker/daemon/execdriver/lxc"
 	"github.com/docker/docker/daemon/execdriver/lxc"
@@ -27,6 +26,7 @@ import (
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/broadcastwriter"
 	"github.com/docker/docker/pkg/broadcastwriter"
 	"github.com/docker/docker/pkg/graphdb"
 	"github.com/docker/docker/pkg/graphdb"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"

+ 2 - 1
daemon/exec.go

@@ -15,6 +15,7 @@ import (
 	"github.com/docker/docker/pkg/broadcastwriter"
 	"github.com/docker/docker/pkg/broadcastwriter"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 )
 )
@@ -254,7 +255,7 @@ func (container *Container) Exec(execConfig *execConfig) error {
 
 
 	// We use a callback here instead of a goroutine and an chan for
 	// We use a callback here instead of a goroutine and an chan for
 	// syncronization purposes
 	// syncronization purposes
-	cErr := utils.Go(func() error { return container.monitorExec(execConfig, callback) })
+	cErr := promise.Go(func() error { return container.monitorExec(execConfig, callback) })
 
 
 	// Exec should not return until the process is actually running
 	// Exec should not return until the process is actually running
 	select {
 	select {

+ 1 - 1
daemon/graphdriver/aufs/aufs.go

@@ -30,8 +30,8 @@ import (
 	"sync"
 	"sync"
 	"syscall"
 	"syscall"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	mountpk "github.com/docker/docker/pkg/mount"
 	mountpk "github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"

+ 1 - 1
daemon/graphdriver/aufs/aufs_test.go

@@ -4,8 +4,8 @@ import (
 	"crypto/sha256"
 	"crypto/sha256"
 	"encoding/hex"
 	"encoding/hex"
 	"fmt"
 	"fmt"
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
+	"github.com/docker/docker/pkg/archive"
 	"io/ioutil"
 	"io/ioutil"
 	"os"
 	"os"
 	"path"
 	"path"

+ 1 - 1
daemon/graphdriver/driver.go

@@ -6,7 +6,7 @@ import (
 	"os"
 	"os"
 	"path"
 	"path"
 
 
-	"github.com/docker/docker/archive"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/mount"
 )
 )
 
 

+ 1 - 1
daemon/graphdriver/fsdiff.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"fmt"
 	"time"
 	"time"
 
 
-	"github.com/docker/docker/archive"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"

+ 1 - 1
daemon/volumes.go

@@ -9,8 +9,8 @@ import (
 	"strings"
 	"strings"
 	"syscall"
 	"syscall"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/volumes"
 	"github.com/docker/docker/volumes"

+ 1 - 1
graph/export.go

@@ -7,8 +7,8 @@ import (
 	"os"
 	"os"
 	"path"
 	"path"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
 )
 )

+ 1 - 1
graph/graph.go

@@ -12,10 +12,10 @@ import (
 	"syscall"
 	"syscall"
 	"time"
 	"time"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/truncindex"
 	"github.com/docker/docker/pkg/truncindex"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"

+ 1 - 1
graph/import.go

@@ -4,8 +4,8 @@ import (
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 )
 )
 
 

+ 1 - 1
graph/load.go

@@ -7,9 +7,9 @@ import (
 	"os"
 	"os"
 	"path"
 	"path"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 )
 )
 
 

+ 1 - 1
graph/push.go

@@ -7,8 +7,8 @@ import (
 	"os"
 	"os"
 	"path"
 	"path"
 
 
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"

+ 1 - 1
image/image.go

@@ -9,7 +9,7 @@ import (
 	"strconv"
 	"strconv"
 	"time"
 	"time"
 
 
-	"github.com/docker/docker/archive"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"

+ 1 - 1
integration-cli/docker_cli_build_test.go

@@ -11,7 +11,7 @@ import (
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
-	"github.com/docker/docker/archive"
+	"github.com/docker/docker/pkg/archive"
 )
 )
 
 
 func TestBuildCacheADD(t *testing.T) {
 func TestBuildCacheADD(t *testing.T) {

+ 1 - 1
integration/graph_test.go

@@ -2,11 +2,11 @@ package docker
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"github.com/docker/docker/archive"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
+	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 	"io"
 	"io"
 	"io/ioutil"
 	"io/ioutil"

+ 0 - 0
archive/MAINTAINERS → pkg/archive/MAINTAINERS


+ 1 - 0
pkg/archive/README.md

@@ -0,0 +1 @@
+This code provides helper functions for dealing with archive files.

+ 4 - 3
archive/archive.go → pkg/archive/archive.go

@@ -18,10 +18,11 @@ import (
 
 
 	"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
 	"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
 
 
+	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/pools"
 	"github.com/docker/docker/pkg/pools"
+	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
-	"github.com/docker/docker/utils"
 )
 )
 
 
 type (
 type (
@@ -370,7 +371,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
 					return nil
 					return nil
 				}
 				}
 
 
-				skip, err := utils.Matches(relFilePath, options.Excludes)
+				skip, err := fileutils.Matches(relFilePath, options.Excludes)
 				if err != nil {
 				if err != nil {
 					log.Debugf("Error matching %s", relFilePath, err)
 					log.Debugf("Error matching %s", relFilePath, err)
 					return err
 					return err
@@ -581,7 +582,7 @@ func CopyFileWithTar(src, dst string) (err error) {
 	}
 	}
 
 
 	r, w := io.Pipe()
 	r, w := io.Pipe()
-	errC := utils.Go(func() error {
+	errC := promise.Go(func() error {
 		defer w.Close()
 		defer w.Close()
 
 
 		srcF, err := os.Open(src)
 		srcF, err := os.Open(src)

+ 0 - 0
archive/archive_test.go → pkg/archive/archive_test.go


+ 0 - 0
archive/changes.go → pkg/archive/changes.go


+ 0 - 0
archive/changes_test.go → pkg/archive/changes_test.go


+ 0 - 0
archive/diff.go → pkg/archive/diff.go


+ 0 - 0
archive/testdata/broken.tar → pkg/archive/testdata/broken.tar


+ 0 - 0
archive/time_linux.go → pkg/archive/time_linux.go


+ 0 - 0
archive/time_unsupported.go → pkg/archive/time_unsupported.go


+ 0 - 0
archive/wrap.go → pkg/archive/wrap.go


+ 26 - 0
pkg/fileutils/fileutils.go

@@ -0,0 +1,26 @@
+package fileutils
+
+import (
+	"github.com/docker/docker/pkg/log"
+	"path/filepath"
+)
+
+// Matches returns true if relFilePath matches any of the patterns
+func Matches(relFilePath string, patterns []string) (bool, error) {
+	for _, exclude := range patterns {
+		matched, err := filepath.Match(exclude, relFilePath)
+		if err != nil {
+			log.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude)
+			return false, err
+		}
+		if matched {
+			if filepath.Clean(relFilePath) == "." {
+				log.Errorf("Can't exclude whole path, excluding pattern: %s", exclude)
+				continue
+			}
+			log.Debugf("Skipping excluded path: %s", relFilePath)
+			return true, nil
+		}
+	}
+	return false, nil
+}

+ 11 - 0
pkg/promise/promise.go

@@ -0,0 +1,11 @@
+package promise
+
+// Go is a basic promise implementation: it wraps calls a function in a goroutine,
+// and returns a channel which will later return the function's return value.
+func Go(f func() error) chan error {
+	ch := make(chan error, 1)
+	go func() {
+		ch <- f()
+	}()
+	return ch
+}

+ 2 - 31
utils/utils.go

@@ -21,6 +21,7 @@ import (
 	"syscall"
 	"syscall"
 
 
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/log"
 	"github.com/docker/docker/pkg/log"
 )
 )
@@ -30,16 +31,6 @@ type KeyValuePair struct {
 	Value string
 	Value string
 }
 }
 
 
-// Go is a basic promise implementation: it wraps calls a function in a goroutine,
-// and returns a channel which will later return the function's return value.
-func Go(f func() error) chan error {
-	ch := make(chan error, 1)
-	go func() {
-		ch <- f()
-	}()
-	return ch
-}
-
 // Request a given URL and return an io.Reader
 // Request a given URL and return an io.Reader
 func Download(url string) (resp *http.Response, err error) {
 func Download(url string) (resp *http.Response, err error) {
 	if resp, err = http.Get(url); err != nil {
 	if resp, err = http.Get(url); err != nil {
@@ -503,7 +494,7 @@ func ValidateContextDirectory(srcPath string, excludes []string) error {
 		// skip this directory/file if it's not in the path, it won't get added to the context
 		// skip this directory/file if it's not in the path, it won't get added to the context
 		if relFilePath, err := filepath.Rel(srcPath, filePath); err != nil {
 		if relFilePath, err := filepath.Rel(srcPath, filePath); err != nil {
 			return err
 			return err
-		} else if skip, err := Matches(relFilePath, excludes); err != nil {
+		} else if skip, err := fileutils.Matches(relFilePath, excludes); err != nil {
 			return err
 			return err
 		} else if skip {
 		} else if skip {
 			if f.IsDir() {
 			if f.IsDir() {
@@ -547,23 +538,3 @@ func StringsContainsNoCase(slice []string, s string) bool {
 	}
 	}
 	return false
 	return false
 }
 }
-
-// Matches returns true if relFilePath matches any of the patterns
-func Matches(relFilePath string, patterns []string) (bool, error) {
-	for _, exclude := range patterns {
-		matched, err := filepath.Match(exclude, relFilePath)
-		if err != nil {
-			log.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude)
-			return false, err
-		}
-		if matched {
-			if filepath.Clean(relFilePath) == "." {
-				log.Errorf("Can't exclude whole path, excluding pattern: %s", exclude)
-				continue
-			}
-			log.Debugf("Skipping excluded path: %s", relFilePath)
-			return true, nil
-		}
-	}
-	return false, nil
-}