refactor: use chart values directly instead of attempting to template out cron-job and keda files
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
{{- $processName := "CRON_ID" }}
|
{{- $processName, $config := range .Values.processes }}
|
||||||
{{- $config := index .Values.processes "CRON_ID" }}
|
# Only process cron jobs
|
||||||
|
{{- if not (and (hasKey $config "cron") (hasKey $config.cron "id")) }}
|
||||||
|
{{- continue }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: CronJob
|
kind: CronJob
|
||||||
@@ -113,3 +116,4 @@ spec:
|
|||||||
successfulJobsHistoryLimit: 10
|
successfulJobsHistoryLimit: 10
|
||||||
suspend: false
|
suspend: false
|
||||||
timeZone: Etc/UTC
|
timeZone: Etc/UTC
|
||||||
|
{{- end }}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||||
{{- $config := index .Values.global.keda.authentications "AUTH_NAME" }}
|
{{- $authName, $config := range .Values.global.keda.authentications }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||||
{{- $config := index .Values.global.keda.authentications "AUTH_NAME" }}
|
{{- $authName, $config := range .Values.global.keda.authentications }}
|
||||||
---
|
---
|
||||||
apiVersion: keda.sh/v1alpha1
|
apiVersion: keda.sh/v1alpha1
|
||||||
kind: TriggerAuthentication
|
kind: TriggerAuthentication
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
|||||||
Processes: map[string]ProcessValues{},
|
Processes: map[string]ProcessValues{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for authName := range kedaValues.Authentications {
|
if len(kedaValues.Authentications) > 0 {
|
||||||
templateFiles := []string{"keda-secret", "keda-trigger-authentication"}
|
templateFiles := []string{"keda-secret", "keda-trigger-authentication"}
|
||||||
for _, templateName := range templateFiles {
|
for _, templateName := range templateFiles {
|
||||||
b, err := templates.ReadFile(fmt.Sprintf("templates/chart/%s.yaml", templateName))
|
b, err := templates.ReadFile(fmt.Sprintf("templates/chart/%s.yaml", templateName))
|
||||||
@@ -376,9 +376,8 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
|||||||
return fmt.Errorf("Error reading %s template: %w", templateName, err)
|
return fmt.Errorf("Error reading %s template: %w", templateName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(chartDir, "templates", fmt.Sprintf("%s-%s.yaml", templateName, authName))
|
filename := filepath.Join(chartDir, "templates", fmt.Sprintf("%s.yaml", templateName))
|
||||||
contents := strings.ReplaceAll(string(b), "AUTH_NAME", authName)
|
err = os.WriteFile(filename, b, os.FileMode(0644))
|
||||||
err = os.WriteFile(filename, []byte(contents), os.FileMode(0644))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error writing %s template: %w", templateName, err)
|
return fmt.Errorf("Error writing %s template: %w", templateName, err)
|
||||||
}
|
}
|
||||||
@@ -613,15 +612,16 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
|||||||
Volumes: processVolumes,
|
Volumes: processVolumes,
|
||||||
}
|
}
|
||||||
values.Processes[cronEntry.ID] = processValues
|
values.Processes[cronEntry.ID] = processValues
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(cronEntries) > 0 {
|
||||||
b, err := templates.ReadFile("templates/chart/cron-job.yaml")
|
b, err := templates.ReadFile("templates/chart/cron-job.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error reading cron job template: %w", err)
|
return fmt.Errorf("Error reading cron job template: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cronFile := filepath.Join(chartDir, "templates", fmt.Sprintf("cron-job-%s.yaml", cronEntry.ID))
|
cronFile := filepath.Join(chartDir, "templates", "cron-job.yaml")
|
||||||
contents := strings.ReplaceAll(string(b), "CRON_ID", cronEntry.ID)
|
err = os.WriteFile(cronFile, b, os.FileMode(0644))
|
||||||
err = os.WriteFile(cronFile, []byte(contents), os.FileMode(0644))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error writing cron job template: %w", err)
|
return fmt.Errorf("Error writing cron job template: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user