CronJob - Allow file ConfigMap & disabling command override (#90)

* allow file configmap on cron-job chart

* Allow disabling the command override in cronjob container

* Use name of volume instead of fileName for configmap naming

* Add YAML separator to configmaps to allow multiple configmap volumes

- before this change if you tried to use e.g. multiple file configmaps they would all be appended in one YAML file due to no usage of separators, which would lead to only one of the file confimaps actually be created.

* Fix broken test due to file configmap naming change
This commit is contained in:
2023-11-16 15:39:13 +01:00
committed by GitHub
parent 5f0d40f05f
commit 0e0f29ee43
7 changed files with 9 additions and 4 deletions
+1
View File
@@ -1,5 +1,6 @@
{{- define "common.configmap.tpl" -}} {{- define "common.configmap.tpl" -}}
{{- if .Values.vars }} {{- if .Values.vars }}
---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
@@ -1,11 +1,11 @@
{{- define "common.customFileConfigmap.tpl" -}} {{- define "common.customFileConfigmap.tpl" -}}
{{- range .Values.volumes }} {{- range .Values.volumes }}
{{- if .fileName }} {{- if .fileName }}
---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: {{ template "common.robustName" .fileName }} name: {{ template "common.robustName" (printf "%s-%s" $.Release.Name .name) }}
namespace: {{ $.Release.Namespace }} namespace: {{ $.Release.Namespace }}
data: data:
{{ .fileName }}: | {{ .fileName }}: |
+1 -1
View File
@@ -10,7 +10,7 @@ volumes:
name: {{ .existingConfigMap }} name: {{ .existingConfigMap }}
{{- else if .fileName }} {{- else if .fileName }}
configMap: configMap:
name: {{ template "common.robustName" .fileName }} name: {{ template "common.robustName" (printf "%s-%s" $.Release.Name .name) }}
{{- else if .hostPath }} {{- else if .hostPath }}
hostPath: hostPath:
path: {{ .hostPath.path }} path: {{ .hostPath.path }}
+2
View File
@@ -25,10 +25,12 @@ spec:
{{- if .Values.vars }} {{- if .Values.vars }}
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- end }} {{- end }}
{{- if .Values.overrideCommand }}
command: command:
- {{ .Values.shell }} - {{ .Values.shell }}
- -c - -c
- {{ .Values.command | quote }} - {{ .Values.command | quote }}
{{- end }}
{{- include "common.envFromRef.tpl" . | nindent 14 }} {{- include "common.envFromRef.tpl" . | nindent 14 }}
{{- include "common.volumeMountsRef.tpl" . | nindent 14 }} {{- include "common.volumeMountsRef.tpl" . | nindent 14 }}
resources: resources:
@@ -0,0 +1 @@
{{- include "common.customFileConfigmap.tpl" . -}}
+1
View File
@@ -5,6 +5,7 @@ image:
schedule: "*/1 * * * *" schedule: "*/1 * * * *"
command: | command: |
echo "I'm alive" echo "I'm alive"
overrideCommand: true
shell: "/bin/sh" shell: "/bin/sh"
nameOverride: "" nameOverride: ""
@@ -169,7 +169,7 @@ tests:
value: value:
- name: volume-name - name: volume-name
configMap: configMap:
name: myfile-conf name: release-name-volume-name
- equal: - equal:
path: spec.template.spec.containers[0].volumeMounts path: spec.template.spec.containers[0].volumeMounts
value: value: