Improve cronjobs
This commit is contained in:
@@ -53,8 +53,9 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
||||
}
|
||||
|
||||
if strings.Contains(image, ":") {
|
||||
image = strings.Split(service.Image, ":")[0]
|
||||
tag = strings.Split(service.Image, ":")[1]
|
||||
parts := strings.Split(image, ":")
|
||||
image = parts[0]
|
||||
tag = parts[1]
|
||||
}
|
||||
|
||||
chart.Values[service.Name].(*Value).CronJob.Repository = &RepositoryValue{
|
||||
@@ -62,6 +63,11 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
||||
Tag: tag,
|
||||
}
|
||||
|
||||
command := mapping.Command
|
||||
if !strings.HasPrefix(command, "sh -c") && !strings.HasPrefix(command, "/bin/sh") {
|
||||
command = "sh -c \"" + command + "\""
|
||||
}
|
||||
|
||||
cronjob := &CronJob{
|
||||
CronJob: &batchv1.CronJob{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
@@ -79,12 +85,13 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
||||
Spec: batchv1.JobSpec{
|
||||
Template: corev1.PodTemplateSpec{
|
||||
Spec: corev1.PodSpec{
|
||||
RestartPolicy: corev1.RestartPolicyOnFailure,
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: "cronjob",
|
||||
Image: "{{ .Values." + service.Name + ".cronjob.repository.image }}:{{ default .Values." + service.Name + ".cronjob.repository.tag \"latest\" }}",
|
||||
Args: []string{
|
||||
mapping.Command,
|
||||
command,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user