Переглянути джерело

Move `exportContainerRw` to the daemon.

Signed-off-by: David Calavera <david.calavera@gmail.com>
David Calavera 9 роки тому
батько
коміт
581380cc6c
2 змінених файлів з 15 додано та 16 видалено
  1. 15 1
      daemon/commit.go
  2. 0 15
      daemon/container.go

+ 15 - 1
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
+}

+ 0 - 15
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