mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #181 from brendandburns/cmd
Fix the container manifest to so that Command is an array, not a string.
This commit is contained in:
commit
33e12cf991
@ -57,7 +57,7 @@ type EnvVar struct {
|
|||||||
type Container struct {
|
type Container struct {
|
||||||
Name string `yaml:"name,omitempty" json:"name,omitempty"`
|
Name string `yaml:"name,omitempty" json:"name,omitempty"`
|
||||||
Image string `yaml:"image,omitempty" json:"image,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"`
|
WorkingDir string `yaml:"workingDir,omitempty" json:"workingDir,omitempty"`
|
||||||
Ports []Port `yaml:"ports,omitempty" json:"ports,omitempty"`
|
Ports []Port `yaml:"ports,omitempty" json:"ports,omitempty"`
|
||||||
Env []EnvVar `yaml:"env,omitempty" json:"env,omitempty"`
|
Env []EnvVar `yaml:"env,omitempty" json:"env,omitempty"`
|
||||||
|
@ -296,14 +296,6 @@ func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, m
|
|||||||
return exposedPorts, portBindings
|
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) {
|
func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.Container) (name string, err error) {
|
||||||
name = manifestAndContainerToDockerName(manifest, container)
|
name = manifestAndContainerToDockerName(manifest, container)
|
||||||
|
|
||||||
@ -319,7 +311,7 @@ func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.
|
|||||||
Env: envVariables,
|
Env: envVariables,
|
||||||
Volumes: volumes,
|
Volumes: volumes,
|
||||||
WorkingDir: container.WorkingDir,
|
WorkingDir: container.WorkingDir,
|
||||||
Cmd: makeCommandLine(container),
|
Cmd: container.Command,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
dockerContainer, err := kl.DockerClient.CreateContainer(opts)
|
dockerContainer, err := kl.DockerClient.CreateContainer(opts)
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"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) {
|
func TestMakeEnvVariables(t *testing.T) {
|
||||||
container := api.Container{
|
container := api.Container{
|
||||||
Env: []api.EnvVar{
|
Env: []api.EnvVar{
|
||||||
|
Loading…
Reference in New Issue
Block a user