move configs structs to remove dependency on daemon

- Moved the following config structs to api/types
   - ContainerRmConfig
   - ContainerCommitConfig

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
Upstream-commit: 63fb931a0b7298c6281898bcc5f53ab0655ad1a6
Component: engine
This commit is contained in:
Morgan Bauer
2015-12-07 09:03:25 -08:00
parent fee5b92987
commit b12523fdf4
11 changed files with 49 additions and 34 deletions
+2 -14
View File
@@ -8,6 +8,7 @@ import (
"time"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/container"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/image"
@@ -17,22 +18,9 @@ import (
"github.com/docker/docker/runconfig"
)
// ContainerCommitConfig contains build configs for commit operation,
// and is used when making a commit with the current state of the container.
type ContainerCommitConfig struct {
Pause bool
Repo string
Tag string
Author string
Comment string
// merge container config into commit config before commit
MergeConfigs bool
Config *runconfig.Config
}
// Commit creates a new filesystem image from the current state of a container.
// The image can optionally be tagged into a repository.
func (daemon *Daemon) Commit(name string, c *ContainerCommitConfig) (string, error) {
func (daemon *Daemon) Commit(name string, c *types.ContainerCommitConfig) (string, error) {
container, err := daemon.Get(name)
if err != nil {
return "", err
+1 -1
View File
@@ -74,7 +74,7 @@ func (daemon *Daemon) create(params *ContainerCreateConfig) (retC *container.Con
}
defer func() {
if retErr != nil {
if err := daemon.ContainerRm(container.ID, &ContainerRmConfig{ForceRemove: true}); err != nil {
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
logrus.Errorf("Clean up Error! Cannot destroy container %s: %v", container.ID, err)
}
}
@@ -11,6 +11,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/builder"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/container"
@@ -105,12 +106,12 @@ func (d Docker) Create(cfg *runconfig.Config, hostCfg *runconfig.HostConfig) (*c
}
// Remove removes a container specified by `id`.
func (d Docker) Remove(id string, cfg *daemon.ContainerRmConfig) error {
func (d Docker) Remove(id string, cfg *types.ContainerRmConfig) error {
return d.Daemon.ContainerRm(id, cfg)
}
// Commit creates a new Docker image from an existing Docker container.
func (d Docker) Commit(name string, cfg *daemon.ContainerCommitConfig) (string, error) {
func (d Docker) Commit(name string, cfg *types.ContainerCommitConfig) (string, error) {
return d.Daemon.Commit(name, cfg)
}
+2 -6
View File
@@ -5,22 +5,18 @@ import (
"path"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/container"
derr "github.com/docker/docker/errors"
"github.com/docker/docker/layer"
volumestore "github.com/docker/docker/volume/store"
)
// ContainerRmConfig is a holder for passing in runtime config.
type ContainerRmConfig struct {
ForceRemove, RemoveVolume, RemoveLink bool
}
// ContainerRm removes the container id from the filesystem. An error
// is returned if the container is not found, or if the remove
// fails. If the remove succeeds, the container name is released, and
// network links are removed.
func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error {
func (daemon *Daemon) ContainerRm(name string, config *types.ContainerRmConfig) error {
container, err := daemon.Get(name)
if err != nil {
return err
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"os"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/container"
"github.com/docker/docker/runconfig"
)
@@ -37,7 +38,7 @@ func TestContainerDoubleDelete(t *testing.T) {
// Try to remove the container when it's start is removalInProgress.
// It should ignore the container and not return an error.
if err := daemon.ContainerRm(container.ID, &ContainerRmConfig{ForceRemove: true}); err != nil {
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
t.Fatal(err)
}
}