From 581380cc6cd26f43fe5e69965873769d8dc739ef Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 2 Nov 2015 17:37:45 -0500 Subject: [PATCH] Move `exportContainerRw` to the daemon. Signed-off-by: David Calavera --- daemon/commit.go | 16 +++++++++++++++- daemon/container.go | 15 --------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/daemon/commit.go b/daemon/commit.go index 62c9a458f4..d92c34ba5d 100644 --- a/daemon/commit.go +++ b/daemon/commit.go @@ -2,6 +2,8 @@ package daemon import ( "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/runconfig" ) @@ -24,7 +26,7 @@ func (daemon *Daemon) Commit(container *Container, c *ContainerCommitConfig) (*i defer container.unpause() } - rwTar, err := container.exportContainerRw() + rwTar, err := daemon.exportContainerRw(container) if err != nil { return nil, err } @@ -49,3 +51,15 @@ func (daemon *Daemon) Commit(container *Container, c *ContainerCommitConfig) (*i container.logEvent("commit") return img, nil } + +func (daemon *Daemon) exportContainerRw(container *Container) (archive.Archive, error) { + archive, err := daemon.diff(container) + if err != nil { + return nil, err + } + return ioutils.NewReadCloserWrapper(archive, func() error { + err := archive.Close() + return err + }), + nil +} diff --git a/daemon/container.go b/daemon/container.go index bdfd9f8e54..1731e05b8d 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -225,21 +225,6 @@ func (container *Container) getRootResourcePath(path string) (string, error) { return symlink.FollowSymlinkInScope(filepath.Join(container.root, cleanPath), container.root) } -func (container *Container) exportContainerRw() (archive.Archive, error) { - if container.daemon == nil { - return nil, derr.ErrorCodeUnregisteredContainer.WithArgs(container.ID) - } - archive, err := container.daemon.diff(container) - if err != nil { - return nil, err - } - return ioutils.NewReadCloserWrapper(archive, func() error { - err := archive.Close() - return err - }), - nil -} - // Start prepares the container to run by setting up everything the // container needs, such as storage and networking, as well as links // between containers. The container is left waiting for a signal to