move configs structs to remove dependency on deamon
| ... | ... |
@@ -38,7 +38,7 @@ type stateBackend interface {
|
| 38 | 38 |
ContainerRename(oldName, newName string) error |
| 39 | 39 |
ContainerResize(name string, height, width int) error |
| 40 | 40 |
ContainerRestart(name string, seconds int) error |
| 41 |
- ContainerRm(name string, config *daemon.ContainerRmConfig) error |
|
| 41 |
+ ContainerRm(name string, config *types.ContainerRmConfig) error |
|
| 42 | 42 |
ContainerStart(name string, hostConfig *runconfig.HostConfig) error |
| 43 | 43 |
ContainerStop(name string, seconds int) error |
| 44 | 44 |
ContainerUnpause(name string) error |
| ... | ... |
@@ -358,7 +358,7 @@ func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseW |
| 358 | 358 |
} |
| 359 | 359 |
|
| 360 | 360 |
name := vars["name"] |
| 361 |
- config := &daemon.ContainerRmConfig{
|
|
| 361 |
+ config := &types.ContainerRmConfig{
|
|
| 362 | 362 |
ForceRemove: httputils.BoolValue(r, "force"), |
| 363 | 363 |
RemoveVolume: httputils.BoolValue(r, "v"), |
| 364 | 364 |
RemoveLink: httputils.BoolValue(r, "link"), |
| 365 | 365 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 0 |
+package types |
|
| 1 |
+ |
|
| 2 |
+// configs holds structs used for internal communication between the |
|
| 3 |
+// frontend (such as an http server) and the backend (such as the |
|
| 4 |
+// docker daemon). |
|
| 5 |
+ |
|
| 6 |
+import ( |
|
| 7 |
+ "github.com/docker/docker/runconfig" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+// ContainerRmConfig holds arguments for the container remove |
|
| 11 |
+// operation. This struct is used to tell the backend what operations |
|
| 12 |
+// to perform. |
|
| 13 |
+type ContainerRmConfig struct {
|
|
| 14 |
+ ForceRemove, RemoveVolume, RemoveLink bool |
|
| 15 |
+} |
|
| 16 |
+ |
|
| 17 |
+// ContainerCommitConfig contains build configs for commit operation, |
|
| 18 |
+// and is used when making a commit with the current state of the container. |
|
| 19 |
+type ContainerCommitConfig struct {
|
|
| 20 |
+ Pause bool |
|
| 21 |
+ Repo string |
|
| 22 |
+ Tag string |
|
| 23 |
+ Author string |
|
| 24 |
+ Comment string |
|
| 25 |
+ // merge container config into commit config before commit |
|
| 26 |
+ MergeConfigs bool |
|
| 27 |
+ Config *runconfig.Config |
|
| 28 |
+} |
| ... | ... |
@@ -8,9 +8,8 @@ import ( |
| 8 | 8 |
"io" |
| 9 | 9 |
"os" |
| 10 | 10 |
|
| 11 |
- // TODO: remove dependency on daemon |
|
| 11 |
+ "github.com/docker/docker/api/types" |
|
| 12 | 12 |
"github.com/docker/docker/container" |
| 13 |
- "github.com/docker/docker/daemon" |
|
| 14 | 13 |
"github.com/docker/docker/image" |
| 15 | 14 |
"github.com/docker/docker/runconfig" |
| 16 | 15 |
) |
| ... | ... |
@@ -122,9 +121,9 @@ type Docker interface {
|
| 122 | 122 |
// TODO: put warnings in the error |
| 123 | 123 |
Create(*runconfig.Config, *runconfig.HostConfig) (*container.Container, []string, error) |
| 124 | 124 |
// Remove removes a container specified by `id`. |
| 125 |
- Remove(id string, cfg *daemon.ContainerRmConfig) error |
|
| 125 |
+ Remove(id string, cfg *types.ContainerRmConfig) error |
|
| 126 | 126 |
// Commit creates a new Docker image from an existing Docker container. |
| 127 |
- Commit(string, *daemon.ContainerCommitConfig) (string, error) |
|
| 127 |
+ Commit(string, *types.ContainerCommitConfig) (string, error) |
|
| 128 | 128 |
// Copy copies/extracts a source FileInfo to a destination path inside a container |
| 129 | 129 |
// specified by a container object. |
| 130 | 130 |
// TODO: make an Extract method instead of passing `decompress` |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"sync" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/Sirupsen/logrus" |
| 13 |
+ "github.com/docker/docker/api/types" |
|
| 13 | 14 |
"github.com/docker/docker/builder" |
| 14 | 15 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 15 | 16 |
"github.com/docker/docker/daemon" |
| ... | ... |
@@ -267,7 +268,7 @@ func Commit(containerName string, d *daemon.Daemon, c *CommitConfig) (string, er |
| 267 | 267 |
return "", err |
| 268 | 268 |
} |
| 269 | 269 |
|
| 270 |
- commitCfg := &daemon.ContainerCommitConfig{
|
|
| 270 |
+ commitCfg := &types.ContainerCommitConfig{
|
|
| 271 | 271 |
Pause: c.Pause, |
| 272 | 272 |
Repo: c.Repo, |
| 273 | 273 |
Tag: c.Tag, |
| ... | ... |
@@ -20,10 +20,10 @@ import ( |
| 20 | 20 |
|
| 21 | 21 |
"github.com/Sirupsen/logrus" |
| 22 | 22 |
"github.com/docker/docker/api" |
| 23 |
+ "github.com/docker/docker/api/types" |
|
| 23 | 24 |
"github.com/docker/docker/builder" |
| 24 | 25 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 25 | 26 |
"github.com/docker/docker/container" |
| 26 |
- "github.com/docker/docker/daemon" |
|
| 27 | 27 |
"github.com/docker/docker/image" |
| 28 | 28 |
"github.com/docker/docker/pkg/archive" |
| 29 | 29 |
"github.com/docker/docker/pkg/httputils" |
| ... | ... |
@@ -77,7 +77,7 @@ func (b *Builder) commit(id string, autoCmd *stringutils.StrSlice, comment strin |
| 77 | 77 |
autoConfig := *b.runConfig |
| 78 | 78 |
autoConfig.Cmd = autoCmd |
| 79 | 79 |
|
| 80 |
- commitCfg := &daemon.ContainerCommitConfig{
|
|
| 80 |
+ commitCfg := &types.ContainerCommitConfig{
|
|
| 81 | 81 |
Author: b.maintainer, |
| 82 | 82 |
Pause: true, |
| 83 | 83 |
Config: &autoConfig, |
| ... | ... |
@@ -586,7 +586,7 @@ func (b *Builder) run(c *container.Container) error {
|
| 586 | 586 |
} |
| 587 | 587 |
|
| 588 | 588 |
func (b *Builder) removeContainer(c string) error {
|
| 589 |
- rmConfig := &daemon.ContainerRmConfig{
|
|
| 589 |
+ rmConfig := &types.ContainerRmConfig{
|
|
| 590 | 590 |
ForceRemove: true, |
| 591 | 591 |
RemoveVolume: true, |
| 592 | 592 |
} |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 | 10 |
"github.com/docker/distribution/reference" |
| 11 |
+ "github.com/docker/docker/api/types" |
|
| 11 | 12 |
"github.com/docker/docker/container" |
| 12 | 13 |
"github.com/docker/docker/dockerversion" |
| 13 | 14 |
"github.com/docker/docker/image" |
| ... | ... |
@@ -17,22 +18,9 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/runconfig" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 |
-// ContainerCommitConfig contains build configs for commit operation, |
|
| 21 |
-// and is used when making a commit with the current state of the container. |
|
| 22 |
-type ContainerCommitConfig struct {
|
|
| 23 |
- Pause bool |
|
| 24 |
- Repo string |
|
| 25 |
- Tag string |
|
| 26 |
- Author string |
|
| 27 |
- Comment string |
|
| 28 |
- // merge container config into commit config before commit |
|
| 29 |
- MergeConfigs bool |
|
| 30 |
- Config *runconfig.Config |
|
| 31 |
-} |
|
| 32 |
- |
|
| 33 | 20 |
// Commit creates a new filesystem image from the current state of a container. |
| 34 | 21 |
// The image can optionally be tagged into a repository. |
| 35 |
-func (daemon *Daemon) Commit(name string, c *ContainerCommitConfig) (string, error) {
|
|
| 22 |
+func (daemon *Daemon) Commit(name string, c *types.ContainerCommitConfig) (string, error) {
|
|
| 36 | 23 |
container, err := daemon.Get(name) |
| 37 | 24 |
if err != nil {
|
| 38 | 25 |
return "", err |
| ... | ... |
@@ -74,7 +74,7 @@ func (daemon *Daemon) create(params *ContainerCreateConfig) (retC *container.Con |
| 74 | 74 |
} |
| 75 | 75 |
defer func() {
|
| 76 | 76 |
if retErr != nil {
|
| 77 |
- if err := daemon.ContainerRm(container.ID, &ContainerRmConfig{ForceRemove: true}); err != nil {
|
|
| 77 |
+ if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
|
|
| 78 | 78 |
logrus.Errorf("Clean up Error! Cannot destroy container %s: %v", container.ID, err)
|
| 79 | 79 |
} |
| 80 | 80 |
} |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 | 12 |
"github.com/docker/distribution/reference" |
| 13 | 13 |
"github.com/docker/docker/api" |
| 14 |
+ "github.com/docker/docker/api/types" |
|
| 14 | 15 |
"github.com/docker/docker/builder" |
| 15 | 16 |
"github.com/docker/docker/cliconfig" |
| 16 | 17 |
"github.com/docker/docker/container" |
| ... | ... |
@@ -105,12 +106,12 @@ func (d Docker) Create(cfg *runconfig.Config, hostCfg *runconfig.HostConfig) (*c |
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
// Remove removes a container specified by `id`. |
| 108 |
-func (d Docker) Remove(id string, cfg *daemon.ContainerRmConfig) error {
|
|
| 108 |
+func (d Docker) Remove(id string, cfg *types.ContainerRmConfig) error {
|
|
| 109 | 109 |
return d.Daemon.ContainerRm(id, cfg) |
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 | 112 |
// Commit creates a new Docker image from an existing Docker container. |
| 113 |
-func (d Docker) Commit(name string, cfg *daemon.ContainerCommitConfig) (string, error) {
|
|
| 113 |
+func (d Docker) Commit(name string, cfg *types.ContainerCommitConfig) (string, error) {
|
|
| 114 | 114 |
return d.Daemon.Commit(name, cfg) |
| 115 | 115 |
} |
| 116 | 116 |
|
| ... | ... |
@@ -5,22 +5,18 @@ import ( |
| 5 | 5 |
"path" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/Sirupsen/logrus" |
| 8 |
+ "github.com/docker/docker/api/types" |
|
| 8 | 9 |
"github.com/docker/docker/container" |
| 9 | 10 |
derr "github.com/docker/docker/errors" |
| 10 | 11 |
"github.com/docker/docker/layer" |
| 11 | 12 |
volumestore "github.com/docker/docker/volume/store" |
| 12 | 13 |
) |
| 13 | 14 |
|
| 14 |
-// ContainerRmConfig is a holder for passing in runtime config. |
|
| 15 |
-type ContainerRmConfig struct {
|
|
| 16 |
- ForceRemove, RemoveVolume, RemoveLink bool |
|
| 17 |
-} |
|
| 18 |
- |
|
| 19 | 15 |
// ContainerRm removes the container id from the filesystem. An error |
| 20 | 16 |
// is returned if the container is not found, or if the remove |
| 21 | 17 |
// fails. If the remove succeeds, the container name is released, and |
| 22 | 18 |
// network links are removed. |
| 23 |
-func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error {
|
|
| 19 |
+func (daemon *Daemon) ContainerRm(name string, config *types.ContainerRmConfig) error {
|
|
| 24 | 20 |
container, err := daemon.Get(name) |
| 25 | 21 |
if err != nil {
|
| 26 | 22 |
return err |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"os" |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/api/types" |
|
| 8 | 9 |
"github.com/docker/docker/container" |
| 9 | 10 |
"github.com/docker/docker/runconfig" |
| 10 | 11 |
) |
| ... | ... |
@@ -37,7 +38,7 @@ func TestContainerDoubleDelete(t *testing.T) {
|
| 37 | 37 |
|
| 38 | 38 |
// Try to remove the container when it's start is removalInProgress. |
| 39 | 39 |
// It should ignore the container and not return an error. |
| 40 |
- if err := daemon.ContainerRm(container.ID, &ContainerRmConfig{ForceRemove: true}); err != nil {
|
|
| 40 |
+ if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
|
|
| 41 | 41 |
t.Fatal(err) |
| 42 | 42 |
} |
| 43 | 43 |
} |