1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Move exportContainerRw to the daemon.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-11-02 17:37:45 -05:00
parent 7e5f904830
commit 581380cc6c
2 changed files with 15 additions and 16 deletions

View file

@ -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
}

View file

@ -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