From ae9fce13584d9da729e0f9e18d0a55bd9ff8acdf Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 19 Jun 2014 20:19:40 -0700 Subject: [PATCH] Fix the container manifest to so that Command is an array, not a string. --- pkg/api/types.go | 2 +- pkg/kubelet/kubelet.go | 10 +--------- pkg/kubelet/kubelet_test.go | 12 ------------ 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 29a71cde7cd..c07a9fa82fc 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -57,7 +57,7 @@ type EnvVar struct { type Container struct { Name string `yaml:"name,omitempty" json:"name,omitempty"` Image string `yaml:"image,omitempty" json:"image,omitempty"` - Command string `yaml:"command,omitempty" json:"command,omitempty"` + Command []string `yaml:"command,omitempty" json:"command,omitempty"` WorkingDir string `yaml:"workingDir,omitempty" json:"workingDir,omitempty"` Ports []Port `yaml:"ports,omitempty" json:"ports,omitempty"` Env []EnvVar `yaml:"env,omitempty" json:"env,omitempty"` diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 620c99df7e5..8392653d947 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -296,14 +296,6 @@ func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, m return exposedPorts, portBindings } -func makeCommandLine(container *api.Container) []string { - var cmdList []string - if len(container.Command) > 0 { - cmdList = strings.Split(container.Command, " ") - } - return cmdList -} - func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.Container) (name string, err error) { name = manifestAndContainerToDockerName(manifest, container) @@ -319,7 +311,7 @@ func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api. Env: envVariables, Volumes: volumes, WorkingDir: container.WorkingDir, - Cmd: makeCommandLine(container), + Cmd: container.Command, }, } dockerContainer, err := kl.DockerClient.CreateContainer(opts) diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 6eea97987ec..af0b5010feb 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -22,7 +22,6 @@ import ( "io/ioutil" "net/http/httptest" "reflect" - "strings" "sync" "testing" @@ -596,17 +595,6 @@ func TestEventWritingError(t *testing.T) { } } -func TestMakeCommandLine(t *testing.T) { - expected := []string{"echo", "hello", "world"} - container := api.Container{ - Command: strings.Join(expected, " "), - } - cmdLine := makeCommandLine(&container) - if !reflect.DeepEqual(expected, cmdLine) { - t.Error("Unexpected command line. Expected %#v, got %#v", expected, cmdLine) - } -} - func TestMakeEnvVariables(t *testing.T) { container := api.Container{ Env: []api.EnvVar{