From b845a62149d5f4990462ac6c9167c5cfaa0e66cb Mon Sep 17 00:00:00 2001 From: Rafe Colton Date: Mon, 29 Sep 2014 23:16:27 -0700 Subject: [PATCH 1/3] Move Go() promise-like func from utils to pkg/promise This is the first of two steps to break the archive package's dependence on utils so that archive may be moved into pkg. Also, the `Go()` function is small, concise, and not specific to the docker internals, so it is a good candidate for pkg. Signed-off-by: Rafe Colton --- api/client/commands.go | 7 ++++--- api/client/hijack.go | 6 +++--- builder/internals.go | 3 ++- daemon/attach.go | 3 ++- daemon/container.go | 3 ++- daemon/exec.go | 3 ++- pkg/promise/promise.go | 11 +++++++++++ utils/utils.go | 10 ---------- 8 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 pkg/promise/promise.go diff --git a/api/client/commands.go b/api/client/commands.go index a6e7defc79..901e992a8c 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -33,6 +33,7 @@ import ( flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers/filters" + "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/timeutils" @@ -648,7 +649,7 @@ func (cli *DockerCli) CmdStart(args ...string) error { v.Set("stdout", "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) }) } @@ -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) }) } else { @@ -2477,7 +2478,7 @@ func (cli *DockerCli) CmdExec(args ...string) error { 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) }) diff --git a/api/client/hijack.go b/api/client/hijack.go index 7a934fde15..00170a4a37 100644 --- a/api/client/hijack.go +++ b/api/client/hijack.go @@ -14,9 +14,9 @@ import ( "github.com/docker/docker/api" "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/log" + "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/term" - "github.com/docker/docker/utils" ) 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 { - receiveStdout = utils.Go(func() (err error) { + receiveStdout = promise.Go(func() (err error) { defer func() { if in != nil { 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 { io.Copy(rwc, in) log.Debugf("[hijack] End of stdin") diff --git a/builder/internals.go b/builder/internals.go index 3e30127b48..1d05b60ee6 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -23,6 +23,7 @@ import ( imagepkg "github.com/docker/docker/image" "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/parsers" + "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/system" "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 { var errCh chan error 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 (LK4D4): Also, maybe makes sense to call "logs" job, it is like attach diff --git a/daemon/attach.go b/daemon/attach.go index 6ad1cbad48..c5d2e7298a 100644 --- a/daemon/attach.go +++ b/daemon/attach.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/jsonlog" "github.com/docker/docker/pkg/log" + "github.com/docker/docker/pkg/promise" "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() { if cStdout != nil { cStdout.Close() diff --git a/daemon/container.go b/daemon/container.go index 5ea2df2af5..c39428c266 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -27,6 +27,7 @@ import ( "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/networkfs/etchosts" "github.com/docker/docker/pkg/networkfs/resolvconf" + "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" @@ -1117,7 +1118,7 @@ func (container *Container) waitForStart() error { // process or until the process is running in the container select { case <-container.monitor.startSignal: - case err := <-utils.Go(container.monitor.Start): + case err := <-promise.Go(container.monitor.Start): return err } diff --git a/daemon/exec.go b/daemon/exec.go index 6ce5b91ddc..272d1e3f1d 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -15,6 +15,7 @@ import ( "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/log" + "github.com/docker/docker/pkg/promise" "github.com/docker/docker/runconfig" "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 // 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 select { diff --git a/pkg/promise/promise.go b/pkg/promise/promise.go new file mode 100644 index 0000000000..dd52b9082f --- /dev/null +++ b/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 +} diff --git a/utils/utils.go b/utils/utils.go index d2fd1ae701..3a14c41699 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -30,16 +30,6 @@ type KeyValuePair struct { 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 func Download(url string) (resp *http.Response, err error) { if resp, err = http.Get(url); err != nil { From 73f4bfed810b65943f1d9d038a8db9bd834067fa Mon Sep 17 00:00:00 2001 From: Rafe Colton Date: Mon, 29 Sep 2014 23:21:41 -0700 Subject: [PATCH 2/3] Move Matches() file path matching function into pkg/fileutils This is the second of two steps to break the archive package's dependence on utils so that archive may be moved into pkg. `Matches()` is also a good candidate pkg in that it is small, concise, and not specific to docker internals Signed-off-by: Rafe Colton --- pkg/fileutils/fileutils.go | 26 ++++++++++++++++++++++++++ utils/utils.go | 23 ++--------------------- 2 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 pkg/fileutils/fileutils.go diff --git a/pkg/fileutils/fileutils.go b/pkg/fileutils/fileutils.go new file mode 100644 index 0000000000..acc27f55b5 --- /dev/null +++ b/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 +} diff --git a/utils/utils.go b/utils/utils.go index 3a14c41699..792b80bd51 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -21,6 +21,7 @@ import ( "syscall" "github.com/docker/docker/dockerversion" + "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/log" ) @@ -493,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 if relFilePath, err := filepath.Rel(srcPath, filePath); err != nil { return err - } else if skip, err := Matches(relFilePath, excludes); err != nil { + } else if skip, err := fileutils.Matches(relFilePath, excludes); err != nil { return err } else if skip { if f.IsDir() { @@ -537,23 +538,3 @@ func StringsContainsNoCase(slice []string, s string) bool { } 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 -} From 30d5a42c1f24e26f681b7330249f04fec891aee9 Mon Sep 17 00:00:00 2001 From: Rafe Colton Date: Mon, 29 Sep 2014 23:23:36 -0700 Subject: [PATCH 3/3] Move archive package into pkg/archive Now that the archive package does not depend on any docker-specific packages, only those in pkg and vendor, it can be safely moved into pkg. Signed-off-by: Rafe Colton --- api/client/commands.go | 2 +- archive/README.md | 3 --- builder/internals.go | 2 +- builder/job.go | 2 +- daemon/container.go | 2 +- daemon/daemon.go | 2 +- daemon/graphdriver/aufs/aufs.go | 2 +- daemon/graphdriver/aufs/aufs_test.go | 2 +- daemon/graphdriver/driver.go | 2 +- daemon/graphdriver/fsdiff.go | 2 +- daemon/volumes.go | 2 +- graph/export.go | 2 +- graph/graph.go | 2 +- graph/import.go | 2 +- graph/load.go | 2 +- graph/push.go | 2 +- image/image.go | 2 +- integration-cli/docker_cli_build_test.go | 2 +- integration/graph_test.go | 2 +- {archive => pkg/archive}/MAINTAINERS | 0 pkg/archive/README.md | 1 + {archive => pkg/archive}/archive.go | 7 ++++--- {archive => pkg/archive}/archive_test.go | 0 {archive => pkg/archive}/changes.go | 0 {archive => pkg/archive}/changes_test.go | 0 {archive => pkg/archive}/diff.go | 0 {archive => pkg/archive}/testdata/broken.tar | Bin {archive => pkg/archive}/time_linux.go | 0 {archive => pkg/archive}/time_unsupported.go | 0 {archive => pkg/archive}/wrap.go | 0 30 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 archive/README.md rename {archive => pkg/archive}/MAINTAINERS (100%) create mode 100644 pkg/archive/README.md rename {archive => pkg/archive}/archive.go (98%) rename {archive => pkg/archive}/archive_test.go (100%) rename {archive => pkg/archive}/changes.go (100%) rename {archive => pkg/archive}/changes_test.go (100%) rename {archive => pkg/archive}/diff.go (100%) rename {archive => pkg/archive}/testdata/broken.tar (100%) rename {archive => pkg/archive}/time_linux.go (100%) rename {archive => pkg/archive}/time_unsupported.go (100%) rename {archive => pkg/archive}/wrap.go (100%) diff --git a/api/client/commands.go b/api/client/commands.go index 901e992a8c..2694bd919c 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -23,12 +23,12 @@ import ( "time" "github.com/docker/docker/api" - "github.com/docker/docker/archive" "github.com/docker/docker/dockerversion" "github.com/docker/docker/engine" "github.com/docker/docker/graph" "github.com/docker/docker/nat" "github.com/docker/docker/opts" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/parsers" diff --git a/archive/README.md b/archive/README.md deleted file mode 100644 index 4eb0c04181..0000000000 --- a/archive/README.md +++ /dev/null @@ -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`. diff --git a/builder/internals.go b/builder/internals.go index 1d05b60ee6..9f49ccf9ee 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -18,9 +18,9 @@ import ( "syscall" "time" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon" imagepkg "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/promise" diff --git a/builder/job.go b/builder/job.go index 1aa2c3b6b9..1558fa3dab 100644 --- a/builder/job.go +++ b/builder/job.go @@ -7,9 +7,9 @@ import ( "os/exec" "strings" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon" "github.com/docker/docker/engine" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/registry" "github.com/docker/docker/utils" diff --git a/daemon/container.go b/daemon/container.go index c39428c266..e0c44e043f 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -16,12 +16,12 @@ import ( "github.com/docker/libcontainer/devices" "github.com/docker/libcontainer/label" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/engine" "github.com/docker/docker/image" "github.com/docker/docker/links" "github.com/docker/docker/nat" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/log" diff --git a/daemon/daemon.go b/daemon/daemon.go index 8f8cff7282..f04820efd9 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -15,7 +15,6 @@ import ( "github.com/docker/libcontainer/label" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/execdriver/execdrivers" "github.com/docker/docker/daemon/execdriver/lxc" @@ -27,6 +26,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/graph" "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/graphdb" "github.com/docker/docker/pkg/ioutils" diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 8dc0f0de1b..8e3ae0b181 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -30,8 +30,8 @@ import ( "sync" "syscall" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/graphdriver" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" mountpk "github.com/docker/docker/pkg/mount" "github.com/docker/docker/utils" diff --git a/daemon/graphdriver/aufs/aufs_test.go b/daemon/graphdriver/aufs/aufs_test.go index a5ea8579e5..cc5b3a2030 100644 --- a/daemon/graphdriver/aufs/aufs_test.go +++ b/daemon/graphdriver/aufs/aufs_test.go @@ -4,8 +4,8 @@ import ( "crypto/sha256" "encoding/hex" "fmt" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/graphdriver" + "github.com/docker/docker/pkg/archive" "io/ioutil" "os" "path" diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index 677a1d7e18..91040db97a 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -6,7 +6,7 @@ import ( "os" "path" - "github.com/docker/docker/archive" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/mount" ) diff --git a/daemon/graphdriver/fsdiff.go b/daemon/graphdriver/fsdiff.go index d9d4434aec..5e9d32c1c8 100644 --- a/daemon/graphdriver/fsdiff.go +++ b/daemon/graphdriver/fsdiff.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/docker/docker/archive" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/log" "github.com/docker/docker/utils" diff --git a/daemon/volumes.go b/daemon/volumes.go index 4f83f6c513..1ee2df4cef 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -9,8 +9,8 @@ import ( "strings" "syscall" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/execdriver" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/volumes" diff --git a/graph/export.go b/graph/export.go index 3f095e796c..86dc5a342a 100644 --- a/graph/export.go +++ b/graph/export.go @@ -7,8 +7,8 @@ import ( "os" "path" - "github.com/docker/docker/archive" "github.com/docker/docker/engine" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/parsers" ) diff --git a/graph/graph.go b/graph/graph.go index f5e1bdbbcd..00c0324ea8 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -12,10 +12,10 @@ import ( "syscall" "time" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/dockerversion" "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/truncindex" "github.com/docker/docker/runconfig" diff --git a/graph/import.go b/graph/import.go index 049742af45..36d0d3fe10 100644 --- a/graph/import.go +++ b/graph/import.go @@ -4,8 +4,8 @@ import ( "net/http" "net/url" - "github.com/docker/docker/archive" "github.com/docker/docker/engine" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/utils" ) diff --git a/graph/load.go b/graph/load.go index b7fb62ba98..753f31d2c9 100644 --- a/graph/load.go +++ b/graph/load.go @@ -7,9 +7,9 @@ import ( "os" "path" - "github.com/docker/docker/archive" "github.com/docker/docker/engine" "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" ) diff --git a/graph/push.go b/graph/push.go index 47cd4342c5..657e147d10 100644 --- a/graph/push.go +++ b/graph/push.go @@ -7,8 +7,8 @@ import ( "os" "path" - "github.com/docker/docker/archive" "github.com/docker/docker/engine" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" "github.com/docker/docker/registry" "github.com/docker/docker/utils" diff --git a/image/image.go b/image/image.go index 9e58cfe724..fabd897d29 100644 --- a/image/image.go +++ b/image/image.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "github.com/docker/docker/archive" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/log" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 46c52c64c9..26df48fb46 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/docker/docker/archive" + "github.com/docker/docker/pkg/archive" ) func TestBuildCacheADD(t *testing.T) { diff --git a/integration/graph_test.go b/integration/graph_test.go index 4b59a5dbf9..203476cbb2 100644 --- a/integration/graph_test.go +++ b/integration/graph_test.go @@ -2,11 +2,11 @@ package docker import ( "errors" - "github.com/docker/docker/archive" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/dockerversion" "github.com/docker/docker/graph" "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" "github.com/docker/docker/utils" "io" "io/ioutil" diff --git a/archive/MAINTAINERS b/pkg/archive/MAINTAINERS similarity index 100% rename from archive/MAINTAINERS rename to pkg/archive/MAINTAINERS diff --git a/pkg/archive/README.md b/pkg/archive/README.md new file mode 100644 index 0000000000..7307d9694f --- /dev/null +++ b/pkg/archive/README.md @@ -0,0 +1 @@ +This code provides helper functions for dealing with archive files. diff --git a/archive/archive.go b/pkg/archive/archive.go similarity index 98% rename from archive/archive.go rename to pkg/archive/archive.go index 59163f84af..7d9103e103 100644 --- a/archive/archive.go +++ b/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/pkg/fileutils" "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/pools" + "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/system" - "github.com/docker/docker/utils" ) type ( @@ -370,7 +371,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) return nil } - skip, err := utils.Matches(relFilePath, options.Excludes) + skip, err := fileutils.Matches(relFilePath, options.Excludes) if err != nil { log.Debugf("Error matching %s", relFilePath, err) return err @@ -581,7 +582,7 @@ func CopyFileWithTar(src, dst string) (err error) { } r, w := io.Pipe() - errC := utils.Go(func() error { + errC := promise.Go(func() error { defer w.Close() srcF, err := os.Open(src) diff --git a/archive/archive_test.go b/pkg/archive/archive_test.go similarity index 100% rename from archive/archive_test.go rename to pkg/archive/archive_test.go diff --git a/archive/changes.go b/pkg/archive/changes.go similarity index 100% rename from archive/changes.go rename to pkg/archive/changes.go diff --git a/archive/changes_test.go b/pkg/archive/changes_test.go similarity index 100% rename from archive/changes_test.go rename to pkg/archive/changes_test.go diff --git a/archive/diff.go b/pkg/archive/diff.go similarity index 100% rename from archive/diff.go rename to pkg/archive/diff.go diff --git a/archive/testdata/broken.tar b/pkg/archive/testdata/broken.tar similarity index 100% rename from archive/testdata/broken.tar rename to pkg/archive/testdata/broken.tar diff --git a/archive/time_linux.go b/pkg/archive/time_linux.go similarity index 100% rename from archive/time_linux.go rename to pkg/archive/time_linux.go diff --git a/archive/time_unsupported.go b/pkg/archive/time_unsupported.go similarity index 100% rename from archive/time_unsupported.go rename to pkg/archive/time_unsupported.go diff --git a/archive/wrap.go b/pkg/archive/wrap.go similarity index 100% rename from archive/wrap.go rename to pkg/archive/wrap.go