From 53b0d62683ee798198c553353dc2106623a9259b Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Mon, 29 Feb 2016 19:28:37 +0800 Subject: [PATCH] Vendor engine-api to 70d266e96080e3c3d63c55a4d8659e00ac1f7e6c Signed-off-by: Qiang Huang --- builder/dockerfile/dispatchers.go | 16 ++-- builder/dockerfile/internals.go | 20 ++--- daemon/commit.go | 6 +- daemon/container_operations_unix.go | 4 +- daemon/daemon.go | 12 ++- daemon/exec.go | 4 +- hack/vendor.sh | 2 +- image/v1/imagev1.go | 2 +- integration-cli/docker_api_containers_test.go | 4 +- integration-cli/docker_cli_build_test.go | 18 ++-- integration-cli/docker_cli_commit_test.go | 4 +- runconfig/compare.go | 16 ++-- runconfig/compare_test.go | 12 +-- runconfig/config_test.go | 12 +-- runconfig/hostconfig_test.go | 4 +- runconfig/opts/parse.go | 12 +-- runconfig/opts/parse_test.go | 2 +- .../docker/engine-api/client/network.go | 86 ------------------- .../engine-api/client/network_connect.go | 17 ++++ .../engine-api/client/network_create.go | 20 +++++ .../engine-api/client/network_disconnect.go | 13 +++ .../engine-api/client/network_inspect.go | 23 +++++ .../docker/engine-api/client/network_list.go | 30 +++++++ .../engine-api/client/network_remove.go | 8 ++ .../docker/engine-api/client/volume.go | 66 -------------- .../docker/engine-api/client/volume_create.go | 19 ++++ .../engine-api/client/volume_inspect.go | 23 +++++ .../docker/engine-api/client/volume_list.go | 31 +++++++ .../docker/engine-api/client/volume_remove.go | 8 ++ .../docker/engine-api/types/auth.go | 13 ++- .../engine-api/types/container/config.go | 4 +- .../engine-api/types/container/host_config.go | 36 ++++---- .../types/container/hostconfig_windows.go | 68 ++++++++++----- .../engine-api/types/strslice/strslice.go | 57 ++---------- .../docker/engine-api/types/types.go | 1 + 35 files changed, 347 insertions(+), 326 deletions(-) delete mode 100644 vendor/src/github.com/docker/engine-api/client/network.go create mode 100644 vendor/src/github.com/docker/engine-api/client/network_connect.go create mode 100644 vendor/src/github.com/docker/engine-api/client/network_create.go create mode 100644 vendor/src/github.com/docker/engine-api/client/network_disconnect.go create mode 100644 vendor/src/github.com/docker/engine-api/client/network_inspect.go create mode 100644 vendor/src/github.com/docker/engine-api/client/network_list.go create mode 100644 vendor/src/github.com/docker/engine-api/client/network_remove.go delete mode 100644 vendor/src/github.com/docker/engine-api/client/volume.go create mode 100644 vendor/src/github.com/docker/engine-api/client/volume_create.go create mode 100644 vendor/src/github.com/docker/engine-api/client/volume_inspect.go create mode 100644 vendor/src/github.com/docker/engine-api/client/volume_list.go create mode 100644 vendor/src/github.com/docker/engine-api/client/volume_remove.go diff --git a/builder/dockerfile/dispatchers.go b/builder/dockerfile/dispatchers.go index a5e8c154f5..cc2d177ccd 100644 --- a/builder/dockerfile/dispatchers.go +++ b/builder/dockerfile/dispatchers.go @@ -310,20 +310,20 @@ func run(b *Builder, args []string, attributes map[string]bool, original string) } config := &container.Config{ - Cmd: strslice.New(args...), + Cmd: strslice.StrSlice(args), Image: b.image, } // stash the cmd cmd := b.runConfig.Cmd - if b.runConfig.Entrypoint.Len() == 0 && b.runConfig.Cmd.Len() == 0 { + if len(b.runConfig.Entrypoint) == 0 && len(b.runConfig.Cmd) == 0 { b.runConfig.Cmd = config.Cmd } // stash the config environment env := b.runConfig.Env - defer func(cmd *strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd) + defer func(cmd strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd) defer func(env []string) { b.runConfig.Env = env }(env) // derive the net build-time environment for this run. We let config @@ -366,7 +366,7 @@ func run(b *Builder, args []string, attributes map[string]bool, original string) if len(cmdBuildEnv) > 0 { sort.Strings(cmdBuildEnv) tmpEnv := append([]string{fmt.Sprintf("|%d", len(cmdBuildEnv))}, cmdBuildEnv...) - saveCmd = strslice.New(append(tmpEnv, saveCmd.Slice()...)...) + saveCmd = strslice.StrSlice(append(tmpEnv, saveCmd...)) } b.runConfig.Cmd = saveCmd @@ -424,7 +424,7 @@ func cmd(b *Builder, args []string, attributes map[string]bool, original string) } } - b.runConfig.Cmd = strslice.New(cmdSlice...) + b.runConfig.Cmd = strslice.StrSlice(cmdSlice) if err := b.commit("", b.runConfig.Cmd, fmt.Sprintf("CMD %q", cmdSlice)); err != nil { return err @@ -455,16 +455,16 @@ func entrypoint(b *Builder, args []string, attributes map[string]bool, original switch { case attributes["json"]: // ENTRYPOINT ["echo", "hi"] - b.runConfig.Entrypoint = strslice.New(parsed...) + b.runConfig.Entrypoint = strslice.StrSlice(parsed) case len(parsed) == 0: // ENTRYPOINT [] b.runConfig.Entrypoint = nil default: // ENTRYPOINT echo hi if runtime.GOOS != "windows" { - b.runConfig.Entrypoint = strslice.New("/bin/sh", "-c", parsed[0]) + b.runConfig.Entrypoint = strslice.StrSlice{"/bin/sh", "-c", parsed[0]} } else { - b.runConfig.Entrypoint = strslice.New("cmd", "/S", "/C", parsed[0]) + b.runConfig.Entrypoint = strslice.StrSlice{"cmd", "/S", "/C", parsed[0]} } } diff --git a/builder/dockerfile/internals.go b/builder/dockerfile/internals.go index 8d2c325aa9..ff3e1a25d2 100644 --- a/builder/dockerfile/internals.go +++ b/builder/dockerfile/internals.go @@ -37,7 +37,7 @@ import ( "github.com/docker/engine-api/types/strslice" ) -func (b *Builder) commit(id string, autoCmd *strslice.StrSlice, comment string) error { +func (b *Builder) commit(id string, autoCmd strslice.StrSlice, comment string) error { if b.disableCommit { return nil } @@ -48,11 +48,11 @@ func (b *Builder) commit(id string, autoCmd *strslice.StrSlice, comment string) if id == "" { cmd := b.runConfig.Cmd if runtime.GOOS != "windows" { - b.runConfig.Cmd = strslice.New("/bin/sh", "-c", "#(nop) "+comment) + b.runConfig.Cmd = strslice.StrSlice{"/bin/sh", "-c", "#(nop) " + comment} } else { - b.runConfig.Cmd = strslice.New("cmd", "/S /C", "REM (nop) "+comment) + b.runConfig.Cmd = strslice.StrSlice{"cmd", "/S /C", "REM (nop) " + comment} } - defer func(cmd *strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd) + defer func(cmd strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd) hit, err := b.probeCache() if err != nil { @@ -171,11 +171,11 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD cmd := b.runConfig.Cmd if runtime.GOOS != "windows" { - b.runConfig.Cmd = strslice.New("/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, srcHash, dest)) + b.runConfig.Cmd = strslice.StrSlice{"/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, srcHash, dest)} } else { - b.runConfig.Cmd = strslice.New("cmd", "/S", "/C", fmt.Sprintf("REM (nop) %s %s in %s", cmdName, srcHash, dest)) + b.runConfig.Cmd = strslice.StrSlice{"cmd", "/S", "/C", fmt.Sprintf("REM (nop) %s %s in %s", cmdName, srcHash, dest)} } - defer func(cmd *strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd) + defer func(cmd strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd) if hit, err := b.probeCache(); err != nil { return err @@ -527,9 +527,9 @@ func (b *Builder) create() (string, error) { b.tmpContainers[c.ID] = struct{}{} fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID)) - if config.Cmd.Len() > 0 { + if len(config.Cmd) > 0 { // override the entry point that may have been picked up from the base image - if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, config.Cmd.Slice()); err != nil { + if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, config.Cmd); err != nil { return "", err } } @@ -567,7 +567,7 @@ func (b *Builder) run(cID string) (err error) { if ret, _ := b.docker.ContainerWait(cID, -1); ret != 0 { // TODO: change error type, because jsonmessage.JSONError assumes HTTP return &jsonmessage.JSONError{ - Message: fmt.Sprintf("The command '%s' returned a non-zero code: %d", b.runConfig.Cmd.ToString(), ret), + Message: fmt.Sprintf("The command '%s' returned a non-zero code: %d", strings.Join(b.runConfig.Cmd, " "), ret), Code: ret, } } diff --git a/daemon/commit.go b/daemon/commit.go index d2de9b126d..7bc7b6f25d 100644 --- a/daemon/commit.go +++ b/daemon/commit.go @@ -70,8 +70,8 @@ func merge(userConf, imageConf *containertypes.Config) error { userConf.Labels = imageConf.Labels } - if userConf.Entrypoint.Len() == 0 { - if userConf.Cmd.Len() == 0 { + if len(userConf.Entrypoint) == 0 { + if len(userConf.Cmd) == 0 { userConf.Cmd = imageConf.Cmd } @@ -151,7 +151,7 @@ func (daemon *Daemon) Commit(name string, c *types.ContainerCommitConfig) (strin h := image.History{ Author: c.Author, Created: time.Now().UTC(), - CreatedBy: strings.Join(container.Config.Cmd.Slice(), " "), + CreatedBy: strings.Join(container.Config.Cmd, " "), Comment: c.Comment, EmptyLayer: true, } diff --git a/daemon/container_operations_unix.go b/daemon/container_operations_unix.go index 4d658d679d..ea4ab2fd11 100644 --- a/daemon/container_operations_unix.go +++ b/daemon/container_operations_unix.go @@ -257,8 +257,8 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro AllowedDevices: allowedDevices, AppArmorProfile: c.AppArmorProfile, AutoCreatedDevices: autoCreatedDevices, - CapAdd: c.HostConfig.CapAdd.Slice(), - CapDrop: c.HostConfig.CapDrop.Slice(), + CapAdd: c.HostConfig.CapAdd, + CapDrop: c.HostConfig.CapDrop, CgroupParent: defaultCgroupParent, GIDMapping: gidMap, GroupAdd: c.HostConfig.GroupAdd, diff --git a/daemon/daemon.go b/daemon/daemon.go index 6199ddc653..20cfb4723a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -412,7 +412,7 @@ func (daemon *Daemon) mergeAndVerifyConfig(config *containertypes.Config, img *i return err } } - if config.Entrypoint.Len() == 0 && config.Cmd.Len() == 0 { + if len(config.Entrypoint) == 0 && len(config.Cmd) == 0 { return fmt.Errorf("No command specified") } return nil @@ -495,13 +495,11 @@ func (daemon *Daemon) generateHostname(id string, config *containertypes.Config) } } -func (daemon *Daemon) getEntrypointAndArgs(configEntrypoint *strslice.StrSlice, configCmd *strslice.StrSlice) (string, []string) { - cmdSlice := configCmd.Slice() - if configEntrypoint.Len() != 0 { - eSlice := configEntrypoint.Slice() - return eSlice[0], append(eSlice[1:], cmdSlice...) +func (daemon *Daemon) getEntrypointAndArgs(configEntrypoint strslice.StrSlice, configCmd strslice.StrSlice) (string, []string) { + if len(configEntrypoint) != 0 { + return configEntrypoint[0], append(configEntrypoint[1:], configCmd...) } - return cmdSlice[0], cmdSlice[1:] + return configCmd[0], configCmd[1:] } func (daemon *Daemon) newContainer(name string, config *containertypes.Config, imgID image.ID) (*container.Container, error) { diff --git a/daemon/exec.go b/daemon/exec.go index 138e437061..56798a5979 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -93,8 +93,8 @@ func (d *Daemon) ContainerExecCreate(config *types.ExecConfig) (string, error) { return "", err } - cmd := strslice.New(config.Cmd...) - entrypoint, args := d.getEntrypointAndArgs(strslice.New(), cmd) + cmd := strslice.StrSlice(config.Cmd) + entrypoint, args := d.getEntrypointAndArgs(strslice.StrSlice{}, cmd) keys := []byte{} if config.DetachKeys != "" { diff --git a/hack/vendor.sh b/hack/vendor.sh index efd81e1012..d025766f17 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -24,7 +24,7 @@ clone git golang.org/x/net 47990a1ba55743e6ef1affd3a14e5bac8553615d https://gith clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 clone git github.com/docker/go-connections v0.2.0 -clone git github.com/docker/engine-api 575694d38967b53e06cafe8b722c72892dd64db0 +clone git github.com/docker/engine-api 70d266e96080e3c3d63c55a4d8659e00ac1f7e6c clone git github.com/RackSec/srslog 6eb773f331e46fbba8eecb8e794e635e75fc04de clone git github.com/imdario/mergo 0.2.1 diff --git a/image/v1/imagev1.go b/image/v1/imagev1.go index 1e45b62bd9..e27ebd4c0a 100644 --- a/image/v1/imagev1.go +++ b/image/v1/imagev1.go @@ -31,7 +31,7 @@ func HistoryFromConfig(imageJSON []byte, emptyLayer bool) (image.History, error) return image.History{ Author: v1Image.Author, Created: v1Image.Created, - CreatedBy: strings.Join(v1Image.ContainerConfig.Cmd.Slice(), " "), + CreatedBy: strings.Join(v1Image.ContainerConfig.Cmd, " "), Comment: v1Image.Comment, EmptyLayer: emptyLayer, }, nil diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 986b7639b4..94c11e61bd 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -532,7 +532,7 @@ func (s *DockerSuite) TestContainerApiCommit(c *check.C) { c.Assert(json.Unmarshal(b, &img), checker.IsNil) cmd := inspectField(c, img.ID, "Config.Cmd") - c.Assert(cmd, checker.Equals, "{[/bin/sh -c touch /test]}", check.Commentf("got wrong Cmd from commit: %q", cmd)) + c.Assert(cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd)) // sanity check, make sure the image is what we think it is dockerCmd(c, "run", img.ID, "ls", "/test") @@ -564,7 +564,7 @@ func (s *DockerSuite) TestContainerApiCommitWithLabelInConfig(c *check.C) { c.Assert(label2, checker.Equals, "value2") cmd := inspectField(c, img.ID, "Config.Cmd") - c.Assert(cmd, checker.Equals, "{[/bin/sh -c touch /test]}", check.Commentf("got wrong Cmd from commit: %q", cmd)) + c.Assert(cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd)) // sanity check, make sure the image is what we think it is dockerCmd(c, "run", img.ID, "ls", "/test") diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index a34efca2da..fc27a0b22f 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -2230,7 +2230,7 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) { func (s *DockerSuite) TestBuildCmd(c *check.C) { name := "testbuildcmd" - expected := "{[/bin/echo Hello World]}" + expected := "[/bin/echo Hello World]" _, err := buildImage(name, `FROM `+minimalBaseImage()+` CMD ["/bin/echo", "Hello World"]`, @@ -2362,7 +2362,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) { } res := inspectField(c, name, "Config.Entrypoint") - expected := "{[/bin/echo]}" + expected := "[/bin/echo]" if res != expected { c.Fatalf("Entrypoint %s, expected %s", res, expected) } @@ -2376,7 +2376,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) { } res = inspectField(c, name2, "Config.Entrypoint") - expected = "{[]}" + expected = "[]" if res != expected { c.Fatalf("Entrypoint %s, expected %s", res, expected) @@ -2386,7 +2386,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) { func (s *DockerSuite) TestBuildEmptyEntrypoint(c *check.C) { name := "testbuildentrypoint" - expected := "{[]}" + expected := "[]" _, err := buildImage(name, `FROM busybox @@ -2405,7 +2405,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypoint(c *check.C) { func (s *DockerSuite) TestBuildEntrypoint(c *check.C) { name := "testbuildentrypoint" - expected := "{[/bin/echo]}" + expected := "[/bin/echo]" _, err := buildImage(name, `FROM `+minimalBaseImage()+` ENTRYPOINT ["/bin/echo"]`, @@ -3087,7 +3087,7 @@ func (s *DockerSuite) TestBuildEntrypointRunCleanup(c *check.C) { } res := inspectField(c, name, "Config.Cmd") // Cmd must be cleaned up - if res != "" { + if res != "[]" { c.Fatalf("Cmd %s, expected nil", res) } } @@ -3164,7 +3164,7 @@ func (s *DockerSuite) TestBuildInheritance(c *check.C) { } res := inspectField(c, name, "Config.Entrypoint") - if expected := "{[/bin/echo]}"; res != expected { + if expected := "[/bin/echo]"; res != expected { c.Fatalf("Entrypoint %s, expected %s", res, expected) } ports2 := inspectField(c, name, "Config.ExposedPorts") @@ -4367,12 +4367,12 @@ func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *check.C) { c.Fatal(err) } res := inspectField(c, name, "Config.Cmd") - if res != "" { + if res != "[]" { c.Fatalf("Cmd %s, expected nil", res) } res = inspectField(c, name, "Config.Entrypoint") - if expected := "{[cat]}"; res != expected { + if expected := "[cat]"; res != expected { c.Fatalf("Entrypoint %s, expected %s", res, expected) } } diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go index 9a4520bba4..086a203124 100644 --- a/integration-cli/docker_cli_commit_test.go +++ b/integration-cli/docker_cli_commit_test.go @@ -129,9 +129,9 @@ func (s *DockerSuite) TestCommitChange(c *check.C) { "Config.ExposedPorts": "map[8080/tcp:{}]", "Config.Env": "[DEBUG=true test=1 PATH=/foo]", "Config.Labels": "map[foo:bar]", - "Config.Cmd": "{[/bin/sh]}", + "Config.Cmd": "[/bin/sh]", "Config.WorkingDir": "/opt", - "Config.Entrypoint": "{[/bin/sh]}", + "Config.Entrypoint": "[/bin/sh]", "Config.User": "testuser", "Config.Volumes": "map[/var/lib/docker:{}]", "Config.OnBuild": "[/usr/local/bin/python-build --dir /app/src]", diff --git a/runconfig/compare.go b/runconfig/compare.go index e774ba2294..61346aabf4 100644 --- a/runconfig/compare.go +++ b/runconfig/compare.go @@ -17,19 +17,17 @@ func Compare(a, b *container.Config) bool { return false } - if a.Cmd.Len() != b.Cmd.Len() || + if len(a.Cmd) != len(b.Cmd) || len(a.Env) != len(b.Env) || len(a.Labels) != len(b.Labels) || len(a.ExposedPorts) != len(b.ExposedPorts) || - a.Entrypoint.Len() != b.Entrypoint.Len() || + len(a.Entrypoint) != len(b.Entrypoint) || len(a.Volumes) != len(b.Volumes) { return false } - aCmd := a.Cmd.Slice() - bCmd := b.Cmd.Slice() - for i := 0; i < len(aCmd); i++ { - if aCmd[i] != bCmd[i] { + for i := 0; i < len(a.Cmd); i++ { + if a.Cmd[i] != b.Cmd[i] { return false } } @@ -49,10 +47,8 @@ func Compare(a, b *container.Config) bool { } } - aEntrypoint := a.Entrypoint.Slice() - bEntrypoint := b.Entrypoint.Slice() - for i := 0; i < len(aEntrypoint); i++ { - if aEntrypoint[i] != bEntrypoint[i] { + for i := 0; i < len(a.Entrypoint); i++ { + if a.Entrypoint[i] != b.Entrypoint[i] { return false } } diff --git a/runconfig/compare_test.go b/runconfig/compare_test.go index e67f659ef9..9c17c553f3 100644 --- a/runconfig/compare_test.go +++ b/runconfig/compare_test.go @@ -34,12 +34,12 @@ func TestCompare(t *testing.T) { volumes3["/test3"] = struct{}{} envs1 := []string{"ENV1=value1", "ENV2=value2"} envs2 := []string{"ENV1=value1", "ENV3=value3"} - entrypoint1 := strslice.New("/bin/sh", "-c") - entrypoint2 := strslice.New("/bin/sh", "-d") - entrypoint3 := strslice.New("/bin/sh", "-c", "echo") - cmd1 := strslice.New("/bin/sh", "-c") - cmd2 := strslice.New("/bin/sh", "-d") - cmd3 := strslice.New("/bin/sh", "-c", "echo") + entrypoint1 := strslice.StrSlice{"/bin/sh", "-c"} + entrypoint2 := strslice.StrSlice{"/bin/sh", "-d"} + entrypoint3 := strslice.StrSlice{"/bin/sh", "-c", "echo"} + cmd1 := strslice.StrSlice{"/bin/sh", "-c"} + cmd2 := strslice.StrSlice{"/bin/sh", "-d"} + cmd3 := strslice.StrSlice{"/bin/sh", "-c", "echo"} labels1 := map[string]string{"LABEL1": "value1", "LABEL2": "value2"} labels2 := map[string]string{"LABEL1": "value1", "LABEL2": "value3"} labels3 := map[string]string{"LABEL1": "value1", "LABEL2": "value2", "LABEL3": "value3"} diff --git a/runconfig/config_test.go b/runconfig/config_test.go index 35a6a0272a..5804b12d0e 100644 --- a/runconfig/config_test.go +++ b/runconfig/config_test.go @@ -16,7 +16,7 @@ import ( type f struct { file string - entrypoint *strslice.StrSlice + entrypoint strslice.StrSlice } func TestDecodeContainerConfig(t *testing.T) { @@ -29,14 +29,14 @@ func TestDecodeContainerConfig(t *testing.T) { if runtime.GOOS != "windows" { image = "ubuntu" fixtures = []f{ - {"fixtures/unix/container_config_1_14.json", strslice.New()}, - {"fixtures/unix/container_config_1_17.json", strslice.New("bash")}, - {"fixtures/unix/container_config_1_19.json", strslice.New("bash")}, + {"fixtures/unix/container_config_1_14.json", strslice.StrSlice{}}, + {"fixtures/unix/container_config_1_17.json", strslice.StrSlice{"bash"}}, + {"fixtures/unix/container_config_1_19.json", strslice.StrSlice{"bash"}}, } } else { image = "windows" fixtures = []f{ - {"fixtures/windows/container_config_1_19.json", strslice.New("cmd")}, + {"fixtures/windows/container_config_1_19.json", strslice.StrSlice{"cmd"}}, } } @@ -55,7 +55,7 @@ func TestDecodeContainerConfig(t *testing.T) { t.Fatalf("Expected %s image, found %s\n", image, c.Image) } - if c.Entrypoint.Len() != f.entrypoint.Len() { + if len(c.Entrypoint) != len(f.entrypoint) { t.Fatalf("Expected %v, found %v\n", f.entrypoint, c.Entrypoint) } diff --git a/runconfig/hostconfig_test.go b/runconfig/hostconfig_test.go index ef82a7143f..f8d266cf0a 100644 --- a/runconfig/hostconfig_test.go +++ b/runconfig/hostconfig_test.go @@ -190,11 +190,11 @@ func TestDecodeHostConfig(t *testing.T) { t.Fatalf("Expected 1 bind, found %d\n", l) } - if c.CapAdd.Len() != 1 && c.CapAdd.Slice()[0] != "NET_ADMIN" { + if len(c.CapAdd) != 1 && c.CapAdd[0] != "NET_ADMIN" { t.Fatalf("Expected CapAdd NET_ADMIN, got %v", c.CapAdd) } - if c.CapDrop.Len() != 1 && c.CapDrop.Slice()[0] != "NET_ADMIN" { + if len(c.CapDrop) != 1 && c.CapDrop[0] != "NET_ADMIN" { t.Fatalf("Expected CapDrop MKNOD, got %v", c.CapDrop) } } diff --git a/runconfig/opts/parse.go b/runconfig/opts/parse.go index cdd43499d0..18f9fc45bd 100644 --- a/runconfig/opts/parse.go +++ b/runconfig/opts/parse.go @@ -228,15 +228,15 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host var ( parsedArgs = cmd.Args() - runCmd *strslice.StrSlice - entrypoint *strslice.StrSlice + runCmd strslice.StrSlice + entrypoint strslice.StrSlice image = cmd.Arg(0) ) if len(parsedArgs) > 1 { - runCmd = strslice.New(parsedArgs[1:]...) + runCmd = strslice.StrSlice(parsedArgs[1:]) } if *flEntrypoint != "" { - entrypoint = strslice.New(*flEntrypoint) + entrypoint = strslice.StrSlice{*flEntrypoint} } var ( @@ -402,8 +402,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host IpcMode: ipcMode, PidMode: pidMode, UTSMode: utsMode, - CapAdd: strslice.New(flCapAdd.GetAll()...), - CapDrop: strslice.New(flCapDrop.GetAll()...), + CapAdd: strslice.StrSlice(flCapAdd.GetAll()), + CapDrop: strslice.StrSlice(flCapDrop.GetAll()), GroupAdd: flGroupAdd.GetAll(), RestartPolicy: restartPolicy, SecurityOpt: securityOpts, diff --git a/runconfig/opts/parse_test.go b/runconfig/opts/parse_test.go index 1da1deaa26..834b51d142 100644 --- a/runconfig/opts/parse_test.go +++ b/runconfig/opts/parse_test.go @@ -648,7 +648,7 @@ func TestParseEntryPoint(t *testing.T) { if err != nil { t.Fatal(err) } - if config.Entrypoint.Len() != 1 && config.Entrypoint.Slice()[0] != "anything" { + if len(config.Entrypoint) != 1 && config.Entrypoint[0] != "anything" { t.Fatalf("Expected entrypoint 'anything', got %v", config.Entrypoint) } } diff --git a/vendor/src/github.com/docker/engine-api/client/network.go b/vendor/src/github.com/docker/engine-api/client/network.go deleted file mode 100644 index 90b9adb29e..0000000000 --- a/vendor/src/github.com/docker/engine-api/client/network.go +++ /dev/null @@ -1,86 +0,0 @@ -package client - -import ( - "encoding/json" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" - "github.com/docker/engine-api/types/network" -) - -// NetworkCreate creates a new network in the docker host. -func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) { - var response types.NetworkCreateResponse - serverResp, err := cli.post("/networks/create", nil, options, nil) - if err != nil { - return response, err - } - - json.NewDecoder(serverResp.body).Decode(&response) - ensureReaderClosed(serverResp) - return response, err -} - -// NetworkRemove removes an existent network from the docker host. -func (cli *Client) NetworkRemove(networkID string) error { - resp, err := cli.delete("/networks/"+networkID, nil, nil) - ensureReaderClosed(resp) - return err -} - -// NetworkConnect connects a container to an existent network in the docker host. -func (cli *Client) NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error { - nc := types.NetworkConnect{ - Container: containerID, - EndpointConfig: config, - } - resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil) - ensureReaderClosed(resp) - return err -} - -// NetworkDisconnect disconnects a container from an existent network in the docker host. -func (cli *Client) NetworkDisconnect(networkID, containerID string, force bool) error { - nd := types.NetworkDisconnect{Container: containerID, Force: force} - resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nd, nil) - ensureReaderClosed(resp) - return err -} - -// NetworkList returns the list of networks configured in the docker host. -func (cli *Client) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) { - query := url.Values{} - if options.Filters.Len() > 0 { - filterJSON, err := filters.ToParam(options.Filters) - if err != nil { - return nil, err - } - - query.Set("filters", filterJSON) - } - var networkResources []types.NetworkResource - resp, err := cli.get("/networks", query, nil) - if err != nil { - return networkResources, err - } - err = json.NewDecoder(resp.body).Decode(&networkResources) - ensureReaderClosed(resp) - return networkResources, err -} - -// NetworkInspect returns the information for a specific network configured in the docker host. -func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error) { - var networkResource types.NetworkResource - resp, err := cli.get("/networks/"+networkID, nil, nil) - if err != nil { - if resp.statusCode == http.StatusNotFound { - return networkResource, networkNotFoundError{networkID} - } - return networkResource, err - } - err = json.NewDecoder(resp.body).Decode(&networkResource) - ensureReaderClosed(resp) - return networkResource, err -} diff --git a/vendor/src/github.com/docker/engine-api/client/network_connect.go b/vendor/src/github.com/docker/engine-api/client/network_connect.go new file mode 100644 index 0000000000..103ab2b3f4 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/network_connect.go @@ -0,0 +1,17 @@ +package client + +import ( + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/network" +) + +// NetworkConnect connects a container to an existent network in the docker host. +func (cli *Client) NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error { + nc := types.NetworkConnect{ + Container: containerID, + EndpointConfig: config, + } + resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil) + ensureReaderClosed(resp) + return err +} diff --git a/vendor/src/github.com/docker/engine-api/client/network_create.go b/vendor/src/github.com/docker/engine-api/client/network_create.go new file mode 100644 index 0000000000..39b249d8c6 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/network_create.go @@ -0,0 +1,20 @@ +package client + +import ( + "encoding/json" + + "github.com/docker/engine-api/types" +) + +// NetworkCreate creates a new network in the docker host. +func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) { + var response types.NetworkCreateResponse + serverResp, err := cli.post("/networks/create", nil, options, nil) + if err != nil { + return response, err + } + + json.NewDecoder(serverResp.body).Decode(&response) + ensureReaderClosed(serverResp) + return response, err +} diff --git a/vendor/src/github.com/docker/engine-api/client/network_disconnect.go b/vendor/src/github.com/docker/engine-api/client/network_disconnect.go new file mode 100644 index 0000000000..3426a87bda --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/network_disconnect.go @@ -0,0 +1,13 @@ +package client + +import ( + "github.com/docker/engine-api/types" +) + +// NetworkDisconnect disconnects a container from an existent network in the docker host. +func (cli *Client) NetworkDisconnect(networkID, containerID string, force bool) error { + nd := types.NetworkDisconnect{Container: containerID, Force: force} + resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nd, nil) + ensureReaderClosed(resp) + return err +} diff --git a/vendor/src/github.com/docker/engine-api/client/network_inspect.go b/vendor/src/github.com/docker/engine-api/client/network_inspect.go new file mode 100644 index 0000000000..e79f2c2436 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/network_inspect.go @@ -0,0 +1,23 @@ +package client + +import ( + "encoding/json" + "net/http" + + "github.com/docker/engine-api/types" +) + +// NetworkInspect returns the information for a specific network configured in the docker host. +func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error) { + var networkResource types.NetworkResource + resp, err := cli.get("/networks/"+networkID, nil, nil) + if err != nil { + if resp.statusCode == http.StatusNotFound { + return networkResource, networkNotFoundError{networkID} + } + return networkResource, err + } + err = json.NewDecoder(resp.body).Decode(&networkResource) + ensureReaderClosed(resp) + return networkResource, err +} diff --git a/vendor/src/github.com/docker/engine-api/client/network_list.go b/vendor/src/github.com/docker/engine-api/client/network_list.go new file mode 100644 index 0000000000..df6d2e44c0 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/network_list.go @@ -0,0 +1,30 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" +) + +// NetworkList returns the list of networks configured in the docker host. +func (cli *Client) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) { + query := url.Values{} + if options.Filters.Len() > 0 { + filterJSON, err := filters.ToParam(options.Filters) + if err != nil { + return nil, err + } + + query.Set("filters", filterJSON) + } + var networkResources []types.NetworkResource + resp, err := cli.get("/networks", query, nil) + if err != nil { + return networkResources, err + } + err = json.NewDecoder(resp.body).Decode(&networkResources) + ensureReaderClosed(resp) + return networkResources, err +} diff --git a/vendor/src/github.com/docker/engine-api/client/network_remove.go b/vendor/src/github.com/docker/engine-api/client/network_remove.go new file mode 100644 index 0000000000..728fdc2211 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/network_remove.go @@ -0,0 +1,8 @@ +package client + +// NetworkRemove removes an existent network from the docker host. +func (cli *Client) NetworkRemove(networkID string) error { + resp, err := cli.delete("/networks/"+networkID, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/vendor/src/github.com/docker/engine-api/client/volume.go b/vendor/src/github.com/docker/engine-api/client/volume.go deleted file mode 100644 index 597e31803d..0000000000 --- a/vendor/src/github.com/docker/engine-api/client/volume.go +++ /dev/null @@ -1,66 +0,0 @@ -package client - -import ( - "encoding/json" - "net/http" - "net/url" - - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" -) - -// VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, error) { - var volumes types.VolumesListResponse - query := url.Values{} - - if filter.Len() > 0 { - filterJSON, err := filters.ToParam(filter) - if err != nil { - return volumes, err - } - query.Set("filters", filterJSON) - } - resp, err := cli.get("/volumes", query, nil) - if err != nil { - return volumes, err - } - - err = json.NewDecoder(resp.body).Decode(&volumes) - ensureReaderClosed(resp) - return volumes, err -} - -// VolumeInspect returns the information about a specific volume in the docker host. -func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) { - var volume types.Volume - resp, err := cli.get("/volumes/"+volumeID, nil, nil) - if err != nil { - if resp.statusCode == http.StatusNotFound { - return volume, volumeNotFoundError{volumeID} - } - return volume, err - } - err = json.NewDecoder(resp.body).Decode(&volume) - ensureReaderClosed(resp) - return volume, err -} - -// VolumeCreate creates a volume in the docker host. -func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) { - var volume types.Volume - resp, err := cli.post("/volumes/create", nil, options, nil) - if err != nil { - return volume, err - } - err = json.NewDecoder(resp.body).Decode(&volume) - ensureReaderClosed(resp) - return volume, err -} - -// VolumeRemove removes a volume from the docker host. -func (cli *Client) VolumeRemove(volumeID string) error { - resp, err := cli.delete("/volumes/"+volumeID, nil, nil) - ensureReaderClosed(resp) - return err -} diff --git a/vendor/src/github.com/docker/engine-api/client/volume_create.go b/vendor/src/github.com/docker/engine-api/client/volume_create.go new file mode 100644 index 0000000000..98e8f796a3 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/volume_create.go @@ -0,0 +1,19 @@ +package client + +import ( + "encoding/json" + + "github.com/docker/engine-api/types" +) + +// VolumeCreate creates a volume in the docker host. +func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) { + var volume types.Volume + resp, err := cli.post("/volumes/create", nil, options, nil) + if err != nil { + return volume, err + } + err = json.NewDecoder(resp.body).Decode(&volume) + ensureReaderClosed(resp) + return volume, err +} diff --git a/vendor/src/github.com/docker/engine-api/client/volume_inspect.go b/vendor/src/github.com/docker/engine-api/client/volume_inspect.go new file mode 100644 index 0000000000..dbd8444800 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/volume_inspect.go @@ -0,0 +1,23 @@ +package client + +import ( + "encoding/json" + "net/http" + + "github.com/docker/engine-api/types" +) + +// VolumeInspect returns the information about a specific volume in the docker host. +func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) { + var volume types.Volume + resp, err := cli.get("/volumes/"+volumeID, nil, nil) + if err != nil { + if resp.statusCode == http.StatusNotFound { + return volume, volumeNotFoundError{volumeID} + } + return volume, err + } + err = json.NewDecoder(resp.body).Decode(&volume) + ensureReaderClosed(resp) + return volume, err +} diff --git a/vendor/src/github.com/docker/engine-api/client/volume_list.go b/vendor/src/github.com/docker/engine-api/client/volume_list.go new file mode 100644 index 0000000000..6659bc39e2 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/volume_list.go @@ -0,0 +1,31 @@ +package client + +import ( + "encoding/json" + "net/url" + + "github.com/docker/engine-api/types" + "github.com/docker/engine-api/types/filters" +) + +// VolumeList returns the volumes configured in the docker host. +func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, error) { + var volumes types.VolumesListResponse + query := url.Values{} + + if filter.Len() > 0 { + filterJSON, err := filters.ToParam(filter) + if err != nil { + return volumes, err + } + query.Set("filters", filterJSON) + } + resp, err := cli.get("/volumes", query, nil) + if err != nil { + return volumes, err + } + + err = json.NewDecoder(resp.body).Decode(&volumes) + ensureReaderClosed(resp) + return volumes, err +} diff --git a/vendor/src/github.com/docker/engine-api/client/volume_remove.go b/vendor/src/github.com/docker/engine-api/client/volume_remove.go new file mode 100644 index 0000000000..a8bd612de0 --- /dev/null +++ b/vendor/src/github.com/docker/engine-api/client/volume_remove.go @@ -0,0 +1,8 @@ +package client + +// VolumeRemove removes a volume from the docker host. +func (cli *Client) VolumeRemove(volumeID string) error { + resp, err := cli.delete("/volumes/"+volumeID, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/vendor/src/github.com/docker/engine-api/types/auth.go b/vendor/src/github.com/docker/engine-api/types/auth.go index 3a899d2aa7..13188775e3 100644 --- a/vendor/src/github.com/docker/engine-api/types/auth.go +++ b/vendor/src/github.com/docker/engine-api/types/auth.go @@ -2,10 +2,15 @@ package types // AuthConfig contains authorization information for connecting to a Registry type AuthConfig struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Auth string `json:"auth,omitempty"` - Email string `json:"email"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth,omitempty"` + + // Email is an optional value associated with the username. + // This field is deprecated and will be removed in a later + // version of docker. + Email string `json:"email,omitempty"` + ServerAddress string `json:"serveraddress,omitempty"` RegistryToken string `json:"registrytoken,omitempty"` } diff --git a/vendor/src/github.com/docker/engine-api/types/container/config.go b/vendor/src/github.com/docker/engine-api/types/container/config.go index b4e6205d21..b8747a5087 100644 --- a/vendor/src/github.com/docker/engine-api/types/container/config.go +++ b/vendor/src/github.com/docker/engine-api/types/container/config.go @@ -24,12 +24,12 @@ type Config struct { OpenStdin bool // Open stdin StdinOnce bool // If true, close stdin after the 1 attached client disconnects. Env []string // List of environment variable to set in the container - Cmd *strslice.StrSlice // Command to run when starting the container + Cmd strslice.StrSlice // Command to run when starting the container ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) Image string // Name of the image as it was passed by the operator (eg. could be symbolic) Volumes map[string]struct{} // List of volumes (mounts) used for the container WorkingDir string // Current directory (PWD) in the command will be launched - Entrypoint *strslice.StrSlice // Entrypoint to run when starting the container + Entrypoint strslice.StrSlice // Entrypoint to run when starting the container NetworkDisabled bool `json:",omitempty"` // Is network disabled MacAddress string `json:",omitempty"` // Mac Address of the container OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile diff --git a/vendor/src/github.com/docker/engine-api/types/container/host_config.go b/vendor/src/github.com/docker/engine-api/types/container/host_config.go index 920c47bd94..8587aa1df1 100644 --- a/vendor/src/github.com/docker/engine-api/types/container/host_config.go +++ b/vendor/src/github.com/docker/engine-api/types/container/host_config.go @@ -213,24 +213,24 @@ type HostConfig struct { VolumesFrom []string // List of volumes to take from other container // Applicable to UNIX platforms - CapAdd *strslice.StrSlice // List of kernel capabilities to add to the container - CapDrop *strslice.StrSlice // List of kernel capabilities to remove from the container - DNS []string `json:"Dns"` // List of DNS server to lookup - DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for - DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for - ExtraHosts []string // List of extra hosts - GroupAdd []string // List of additional groups that the container process will run as - IpcMode IpcMode // IPC namespace to use for the container - Links []string // List of links (in the name:alias form) - OomScoreAdj int // Container preference for OOM-killing - PidMode PidMode // PID namespace to use for the container - Privileged bool // Is the container in privileged mode - PublishAllPorts bool // Should docker publish all exposed port for the container - ReadonlyRootfs bool // Is the container root filesystem in read-only - SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. - Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container - UTSMode UTSMode // UTS namespace to use for the container - ShmSize int64 // Total shm memory usage + CapAdd strslice.StrSlice // List of kernel capabilities to add to the container + CapDrop strslice.StrSlice // List of kernel capabilities to remove from the container + DNS []string `json:"Dns"` // List of DNS server to lookup + DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for + DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for + ExtraHosts []string // List of extra hosts + GroupAdd []string // List of additional groups that the container process will run as + IpcMode IpcMode // IPC namespace to use for the container + Links []string // List of links (in the name:alias form) + OomScoreAdj int // Container preference for OOM-killing + PidMode PidMode // PID namespace to use for the container + Privileged bool // Is the container in privileged mode + PublishAllPorts bool // Should docker publish all exposed port for the container + ReadonlyRootfs bool // Is the container root filesystem in read-only + SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. + Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container + UTSMode UTSMode // UTS namespace to use for the container + ShmSize int64 // Total shm memory usage // Applicable to Windows ConsoleSize [2]int // Initial console size diff --git a/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go b/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go index e05e56d214..a36715531d 100644 --- a/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go +++ b/vendor/src/github.com/docker/engine-api/types/container/hostconfig_windows.go @@ -15,9 +15,38 @@ func (n NetworkMode) IsNone() bool { return n == "none" } +// IsContainer indicates whether container uses a container network stack. +// Returns false as windows doesn't support this mode +func (n NetworkMode) IsContainer() bool { + return false +} + +// IsBridge indicates whether container uses the bridge network stack +// in windows it is given the name NAT +func (n NetworkMode) IsBridge() bool { + return n == "nat" +} + +// IsHost indicates whether container uses the host network stack. +// returns false as this is not supported by windows +func (n NetworkMode) IsHost() bool { + return false +} + +// IsPrivate indicates whether container uses it's private network stack. +func (n NetworkMode) IsPrivate() bool { + return !(n.IsHost() || n.IsContainer()) +} + +// ConnectedContainer is the id of the container which network this container is connected to. +// Returns blank string on windows +func (n NetworkMode) ConnectedContainer() string { + return "" +} + // IsUserDefined indicates user-created network func (n NetworkMode) IsUserDefined() bool { - return !n.IsDefault() && !n.IsNone() + return !n.IsDefault() && !n.IsNone() && !n.IsBridge() } // IsHyperV indicates the use of a Hyper-V partition for isolation @@ -35,34 +64,19 @@ func (i Isolation) IsValid() bool { return i.IsDefault() || i.IsHyperV() || i.IsProcess() } -// DefaultDaemonNetworkMode returns the default network stack the daemon should -// use. -func DefaultDaemonNetworkMode() NetworkMode { - return NetworkMode("default") -} - // NetworkName returns the name of the network stack. func (n NetworkMode) NetworkName() string { if n.IsDefault() { return "default" + } else if n.IsBridge() { + return "nat" + } else if n.IsNone() { + return "none" + } else if n.IsUserDefined() { + return n.UserDefined() } - return "" -} -// ValidateNetMode ensures that the various combinations of requested -// network settings are valid. -func ValidateNetMode(c *Config, hc *HostConfig) error { - // We may not be passed a host config, such as in the case of docker commit - if hc == nil { - return nil - } - parts := strings.Split(string(hc.NetworkMode), ":") - switch mode := parts[0]; mode { - case "default", "none": - default: - return fmt.Errorf("invalid --net: %s", hc.NetworkMode) - } - return nil + return "" } // ValidateIsolationperforms platform specific validation of the @@ -78,3 +92,11 @@ func ValidateIsolation(hc *HostConfig) error { } return nil } + +//UserDefined indicates user-created network +func (n NetworkMode) UserDefined() string { + if n.IsUserDefined() { + return string(n) + } + return "" +} diff --git a/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go b/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go index 9f3ee620a3..bad493fb89 100644 --- a/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go +++ b/vendor/src/github.com/docker/engine-api/types/strslice/strslice.go @@ -1,29 +1,18 @@ package strslice -import ( - "encoding/json" - "strings" -) +import "encoding/json" // StrSlice represents a string or an array of strings. // We need to override the json decoder to accept both options. -type StrSlice struct { - parts []string -} +type StrSlice []string -// MarshalJSON Marshals (or serializes) the StrSlice into the json format. -// This method is needed to implement json.Marshaller. -func (e *StrSlice) MarshalJSON() ([]byte, error) { - if e == nil { - return []byte{}, nil - } - return json.Marshal(e.Slice()) -} - -// UnmarshalJSON decodes the byte slice whether it's a string or an array of strings. -// This method is needed to implement json.Unmarshaler. +// UnmarshalJSON decodes the byte slice whether it's a string or an array of +// strings. This method is needed to implement json.Unmarshaler. func (e *StrSlice) UnmarshalJSON(b []byte) error { if len(b) == 0 { + // With no input, we preserve the existing value by returning nil and + // leaving the target alone. This allows defining default values for + // the type. return nil } @@ -36,36 +25,6 @@ func (e *StrSlice) UnmarshalJSON(b []byte) error { p = append(p, s) } - e.parts = p + *e = p return nil } - -// Len returns the number of parts of the StrSlice. -func (e *StrSlice) Len() int { - if e == nil { - return 0 - } - return len(e.parts) -} - -// Slice gets the parts of the StrSlice as a Slice of string. -func (e *StrSlice) Slice() []string { - if e == nil { - return nil - } - return e.parts -} - -// ToString gets space separated string of all the parts. -func (e *StrSlice) ToString() string { - s := e.Slice() - if s == nil { - return "" - } - return strings.Join(s, " ") -} - -// New creates an StrSlice based on the specified parts (as strings). -func New(parts ...string) *StrSlice { - return &StrSlice{parts} -} diff --git a/vendor/src/github.com/docker/engine-api/types/types.go b/vendor/src/github.com/docker/engine-api/types/types.go index 478121d165..15228db53a 100644 --- a/vendor/src/github.com/docker/engine-api/types/types.go +++ b/vendor/src/github.com/docker/engine-api/types/types.go @@ -218,6 +218,7 @@ type Info struct { SystemTime string ExecutionDriver string LoggingDriver string + CgroupDriver string NEventsListener int KernelVersion string OperatingSystem string