123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- {{- $name := .Chart.Name }}
- {{- $globalAnnotationsCheck := include "global.annotations.check" . }}
- {{- $globalContEnvsCheck := include "global.containers.envs.check" . }}
- {{- $globalContExtraCheck := include "global.containers.extraEnvs.check" . }}
- {{- $globalContRegistry := include "global.containers.registry" . }}
- {{- $globalInitEnvsCheck := include "global.initContainers.envs.check" . }}
- {{- $globalInitExtraCheck := include "global.initContainers.extraEnvs.check" . }}
- {{- $globalInitRegistry := include "global.initContainers.registry" . }}
- {{- range $index, $val := .Values.items }}
- {{- if and (eq $val.type "job") (not $val.schedule) }}
- apiVersion: batch/v1
- kind: Job
- metadata:
- {{- if or $val.annotations $globalAnnotationsCheck }}
- annotations:
- {{- if $val.annotations }}
- {{- toYaml $val.annotations | nindent 4 }}
- {{- end }}
- {{- if $globalAnnotationsCheck }}
- {{- range $Index, $Val := $.Values.items }}
- {{- if eq $Val.type "global" }}
- {{- toYaml $Val.annotations | nindent 4 }}
- {{- end }}{{- end }}{{- end }}
- {{- end }}
- name: {{ print $val.name | default (print $name "-" $val.type "-" $index) }}
- labels:
- app: {{ $name }}
- tier: {{ $val.name | default (print $name "-" $val.type) }}
- spec:
- {{- if $val.backoffLimit }}
- backoffLimit: {{ $val.backoffLimit }}
- {{- end }}
- {{- if $val.activeDeadlineSeconds }}
- activeDeadlineSeconds: {{ $val.activeDeadlineSeconds }}
- {{- end }}
- template:
- spec:
- {{- if $val.volumes }}
- volumes:
- {{- toYaml .volumes | nindent 8 }}
- {{- end }}
- restartPolicy: {{ $val.restartPolicy | default (print "OnFailure") }}
- {{- if $val.imagePullSecrets.enabled }}
- imagePullSecrets:
- - name: {{ $val.imagePullSecrets.name | default (print $name "-dockerconfig") }}
- {{- end }}
- {{- if $val.initContainers }}
- initContainers:
- {{- range $indexInitContainers, $valInitContainers := $val.initContainers }}
- - name: {{ $valInitContainers.name | default (print $name "-init-" $indexInitContainers) }}
- {{- if not $globalInitRegistry }}
- image: {{ print (default "registry.hub.docker.com" $valInitContainers.registry) "/"
- $valInitContainers.image ":" (default "latest" $valInitContainers.imageTag ) }}
- {{- else }}
- image: {{ print $globalInitRegistry "/"
- $valInitContainers.image ":" (default "latest" $valInitContainers.imageTag ) }}
- {{- end }}
- {{- with $valInitContainers.command }}
- command:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valInitContainers.args }}
- args:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valInitContainers.volumeMounts }}
- volumeMounts:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valInitContainers.resources }}
- resources:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valInitContainers.ports }}
- ports:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- if $valInitContainers.imagePullPolicy }}
- imagePullPolicy: {{ $valInitContainers.imagePullPolicy }}
- {{- end }}
- {{- if not (or $valInitContainers.envs $globalInitEnvsCheck) }}
- {{- if or $valInitContainers.configMap $valInitContainers.secret $valInitContainers.extraEnvs $globalInitExtraCheck }}
- {{- if or $valInitContainers.configMap $valInitContainers.secret }}
- {{- if or $valInitContainers.configMap.enabled $valInitContainers.secret.enabled }}
- envFrom:
- {{- if $valInitContainers.configMap.enabled }}
- - configMapRef:
- name: {{ $valInitContainers.configMap.name | default (print $name "-config") }}
- {{- end }}
- {{- if $valInitContainers.secret.enabled }}
- - secretRef:
- name: {{ $valInitContainers.secret.name | default (print $name "-secret") }}
- {{- end }}
- {{- end }}{{- end }}
- {{- if or $valInitContainers.extraEnvs $globalInitExtraCheck }}
- env:
- {{- if $valInitContainers.extraEnvs }}
- {{- range $valInitContainers.extraEnvs }}{{- if .value }}
- - name: {{ .name }}
- value: {{ .value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- range $Ind, $Val := $.Values.items }}
- {{- if eq $Val.type "global" }}
- {{- range $_, $containers := $Val.containers }}
- {{- range $__, $containersExtraEnvs := $containers.extraEnvs }}{{- if $containersExtraEnvs.value }}
- - name: {{ $containersExtraEnvs.name }}
- value: {{ $containersExtraEnvs.value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- end }}{{- end }}
- {{- end }}
- {{- end }}
- {{- else }}
- env:
- {{- if and (not $globalInitEnvsCheck) $valInitContainers.envs }}
- {{- range $valInitContainers.envs }}{{- if .value }}
- - name: {{ .name }}
- value: {{ .value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- if $globalInitEnvsCheck }}
- {{- range $Ind, $Val := $.Values.items }}
- {{- if eq $Val.type "global" }}
- {{- range $_, $containers := $Val.containers }}
- {{- range $__, $containersEnvs := $containers.envs }}{{- if $containersEnvs.value }}
- - name: {{ $containersEnvs.name }}
- value: {{ $containersEnvs.value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- end }}{{- end }}
- {{- end }}
- {{- end }}
- {{- end }}
- {{- end }}
- {{- if $val.containers }}
- containers:
- {{- range $indexContainers, $valContainers := $val.containers }}
- - name: {{ $valContainers.name | default (print $name "-cont-" $indexContainers) }}
- {{- if not $globalContRegistry }}
- image: {{ print (default "registry.hub.docker.com" $valContainers.registry) "/"
- $valContainers.image ":" (default "latest" $valContainers.imageTag ) }}
- {{- else }}
- image: {{ print $globalContRegistry "/"
- $valContainers.image ":" (default "latest" $valContainers.imageTag ) }}
- {{- end }}
- {{- with $valContainers.command }}
- command:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valContainers.args }}
- args:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valContainers.volumeMounts }}
- volumeMounts:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valContainers.livenessProbe }}
- livenessProbe:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valContainers.readinessProbe }}
- readinessProbe:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valContainers.resources }}
- resources:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- with $valContainers.ports }}
- ports:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- if $valContainers.imagePullPolicy }}
- imagePullPolicy: {{ $valContainers.imagePullPolicy }}
- {{- end }}
- {{- if not (or $valContainers.envs $globalContEnvsCheck) }}
- {{- if or $valContainers.configMap $valContainers.secret $valContainers.extraEnvs $globalContExtraCheck }}
- {{- if or $valContainers.configMap $valContainers.secret }}
- {{- if or $valContainers.configMap.enabled $valContainers.secret.enabled }}
- envFrom:
- {{- if $valContainers.configMap.enabled }}
- - configMapRef:
- name: {{ $valContainers.configMap.name | default (print $name "-config") }}
- {{- end }}
- {{- if $valContainers.secret.enabled }}
- - secretRef:
- name: {{ $valContainers.secret.name | default (print $name "-secret") }}
- {{- end }}
- {{- end }}{{- end }}
- {{- if or $valContainers.extraEnvs $globalContExtraCheck }}
- env:
- {{- if $valContainers.extraEnvs }}
- {{- range $valContainers.extraEnvs }}{{- if .value }}
- - name: {{ .name }}
- value: {{ .value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- range $Ind, $Val := $.Values.items }}
- {{- if eq $Val.type "global" }}
- {{- range $_, $containers := $Val.containers }}
- {{- range $__, $containersExtraEnvs := $containers.extraEnvs }}{{- if $containersExtraEnvs.value }}
- - name: {{ $containersExtraEnvs.name }}
- value: {{ $containersExtraEnvs.value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- end }}{{- end }}
- {{- end }}
- {{- end }}
- {{- else }}
- env:
- {{- if and (not $globalContEnvsCheck) $valContainers.envs }}
- {{- range $valContainers.envs }}{{- if .value }}
- - name: {{ .name }}
- value: {{ .value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- if $globalContEnvsCheck }}
- {{- range $Ind, $Val := $.Values.items }}
- {{- if eq $Val.type "global" }}
- {{- range $_, $containers := $Val.containers }}
- {{- range $__, $containersEnvs := $containers.envs }}{{- if $containersEnvs.value }}
- - name: {{ $containersEnvs.name }}
- value: {{ $containersEnvs.value | quote }}
- {{- end }}{{- end }}{{- end }}
- {{- end }}{{- end }}
- {{- end }}
- {{- end }}
- {{- end }}
- {{- end }}
- {{ print "---" }}
- {{- end }}{{- end }}
|