Skip to content
Snippets Groups Projects
Unverified Commit 4cf44ac5 authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Introduce updated API syntax for command and entrypoint

parent e4fb3704
Branches
Tags
No related merge requests found
......@@ -153,24 +153,8 @@ type Steps []Step
type Image struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Command string `json:"command,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
}
func (i *Image) GetEntrypoint() []string {
return i.getCommand(i.Entrypoint)
}
func (i *Image) GetCommand() []string {
return i.getCommand(i.Command)
}
func (i *Image) getCommand(command string) []string {
if command == "" {
return []string{}
}
return strings.Split(command, " ")
Command []string `json:"command,omitempty"`
Entrypoint []string `json:"entrypoint,omitempty"`
}
type Services []Image
......
......@@ -577,11 +577,11 @@ func (s *executor) createService(service, version, image string, serviceDefiniti
Env: s.getServiceVariables(),
}
if serviceDefinition.Command != "" {
config.Cmd = serviceDefinition.GetCommand()
if len(serviceDefinition.Command) > 0 {
config.Cmd = serviceDefinition.Command
}
if serviceDefinition.Entrypoint != "" {
config.Entrypoint = serviceDefinition.GetEntrypoint()
if len(serviceDefinition.Entrypoint) > 0 {
config.Entrypoint = serviceDefinition.Entrypoint
}
hostConfig := &container.HostConfig{
......@@ -752,8 +752,8 @@ func (s *executor) createContainer(containerType string, imageDefinition common.
Env: append(s.Build.GetAllVariables().StringList(), s.BuildShell.Environment...),
}
if imageDefinition.Entrypoint != "" {
config.Entrypoint = imageDefinition.GetEntrypoint()
if len(imageDefinition.Entrypoint) > 0 {
config.Entrypoint = imageDefinition.Entrypoint
}
nanoCPUs, err := s.Config.Docker.GetNanoCPUs()
......
......@@ -318,13 +318,13 @@ func TestDockerExtendedConfigurationFromJob(t *testing.T) {
{
image: common.Image{
Name: "$IMAGE_NAME",
Entrypoint: "sh -c",
Entrypoint: []string{"sh", "-c"},
},
services: common.Services{
common.Image{
Name: "$SERVICE_NAME",
Entrypoint: "sh -c",
Command: "dockerd-entrypoint.sh",
Entrypoint: []string{"sh", "-c"},
Command: []string{"dockerd-entrypoint.sh"},
Alias: "my-docker-service",
},
},
......
......@@ -341,14 +341,14 @@ func getRequestJobResponse() (res map[string]interface{}) {
image := make(map[string]interface{})
image["name"] = "ruby:2.0"
image["entrypoint"] = "/bin/sh"
image["entrypoint"] = []string{"/bin/sh"}
res["image"] = image
services := make([]map[string]interface{}, 2)
services[0] = make(map[string]interface{})
services[0]["name"] = "postgresql:9.5"
services[0]["entrypoint"] = "/bin/sh"
services[0]["command"] = "sleep 30"
services[0]["entrypoint"] = []string{"/bin/sh"}
services[0]["command"] = []string{"sleep", "30"}
services[0]["alias"] = "db-pg"
services[1] = make(map[string]interface{})
services[1]["name"] = "mysql:5.6"
......@@ -479,11 +479,11 @@ func TestRequestJob(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, "ruby:2.0", res.Image.Name)
assert.Equal(t, "/bin/sh", res.Image.Entrypoint)
assert.Equal(t, []string{"/bin/sh"}, res.Image.Entrypoint)
require.Len(t, res.Services, 2)
assert.Equal(t, "postgresql:9.5", res.Services[0].Name)
assert.Equal(t, "/bin/sh", res.Services[0].Entrypoint)
assert.Equal(t, "sleep 30", res.Services[0].Command)
assert.Equal(t, []string{"/bin/sh"}, res.Services[0].Entrypoint)
assert.Equal(t, []string{"sleep", "30"}, res.Services[0].Command)
assert.Equal(t, "db-pg", res.Services[0].Alias)
assert.Equal(t, "mysql:5.6", res.Services[1].Name)
assert.Equal(t, "db-mysql", res.Services[1].Alias)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment