fix(generator): use args and command #164
@@ -83,9 +83,7 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
||||
{
|
||||
Name: "cronjob",
|
||||
Image: "{{ .Values." + service.Name + ".cronjob.repository.image }}:{{ default .Values." + service.Name + ".cronjob.repository.tag \"latest\" }}",
|
||||
Command: []string{
|
||||
"sh",
|
||||
"-c",
|
||||
Args: []string{
|
||||
mapping.Command,
|
||||
},
|
||||
},
|
||||
|
@@ -38,8 +38,8 @@ services:
|
||||
if cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image != "alpine:latest" {
|
||||
t.Errorf("Expected image to be alpine, got %s", cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image)
|
||||
}
|
||||
combinedCommand := strings.Join(cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Command, " ")
|
||||
if combinedCommand != "sh -c echo hello" {
|
||||
combinedCommand := strings.Join(cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Args, " ")
|
||||
if combinedCommand != "echo hello" {
|
||||
t.Errorf("Expected command to be sh -c echo hello, got %s", combinedCommand)
|
||||
}
|
||||
if cronJob.Spec.Schedule != "*/1 * * * *" {
|
||||
|
@@ -137,7 +137,8 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) {
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: corev1.ResourceList{},
|
||||
},
|
||||
Command: service.Command,
|
||||
Command: service.Entrypoint,
|
||||
Args: service.Command,
|
||||
}
|
||||
if _, ok := d.chart.Values[service.Name]; !ok {
|
||||
d.chart.Values[service.Name] = NewValue(service, d.isMainApp)
|
||||
|
@@ -524,7 +524,7 @@ services:
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
// find the command in the container
|
||||
command := dt.Spec.Template.Spec.Containers[0].Command
|
||||
command := dt.Spec.Template.Spec.Containers[0].Args
|
||||
if len(command) != 3 {
|
||||
t.Errorf("Expected command to have 3 elements, got %d", len(command))
|
||||
}
|
||||
@@ -532,3 +532,34 @@ services:
|
||||
t.Errorf("Expected command to be 'sh -c', got %s", strings.Join(command, " "))
|
||||
}
|
||||
}
|
||||
|
||||
func TestEntryPoint(t *testing.T) {
|
||||
composeFile := `
|
||||
services:
|
||||
web:
|
||||
image: nginx:1.29
|
||||
entrypoint: /bin/foo
|
||||
command: bar baz
|
||||
`
|
||||
tmpDir := setup(composeFile)
|
||||
defer teardown(tmpDir)
|
||||
|
||||
currentDir, _ := os.Getwd()
|
||||
os.Chdir(tmpDir)
|
||||
defer os.Chdir(currentDir)
|
||||
|
||||
output := internalCompileTest(t, "-s", "templates/web/deployment.yaml")
|
||||
t.Logf("Output: %s", output)
|
||||
deployment := v1.Deployment{}
|
||||
if err := yaml.Unmarshal([]byte(output), &deployment); err != nil {
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
entryPoint := deployment.Spec.Template.Spec.Containers[0].Command
|
||||
command := deployment.Spec.Template.Spec.Containers[0].Args
|
||||
if entryPoint[0] != "/bin/foo" {
|
||||
t.Errorf("Expected entrypoint to be /bin/foo, got %s", entryPoint[0])
|
||||
}
|
||||
if len(command) != 2 || command[0] != "bar" || command[1] != "baz" {
|
||||
t.Errorf("Expected command to be 'bar baz', got %s", strings.Join(command, " "))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user