Skip to content

Commit d6224c8

Browse files
authored
refactor logic for lapels and annotations and fix resources
1 parent 88ccbc1 commit d6224c8

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

templates/cronjob.yaml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,13 @@ spec:
3030
metadata:
3131
labels:
3232
release: {{ .Release.Name }}
33-
{{- if .Values.garbageCollect.podLabels }}
34-
{{- with .Values.garbageCollect.podLabels }}
35-
{{- toYaml . | nindent 12 }}
36-
{{- end }}
37-
{{- else if .Values.podLabels }}
38-
{{- with .Values.podLabels }}
39-
{{- toYaml . | nindent 12 }}
40-
{{- end }}
33+
{{- if or .Values.podLabels .Values.garbageCollect.podLabels }}
34+
{{- toYaml (merge (.Values.podLabels | default (dict)) (.Values.garbageCollect.podLabels | default (dict))) | nindent 12 }}
4135
{{- end }}
36+
{{- if or .Values.podAnnotations .Values.garbageCollect.podAnnotations }}
4237
annotations:
43-
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
44-
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
45-
{{- if .Values.garbageCollect.podAnnotations }}
46-
{{- with .Values.garbageCollect.podAnnotations }}
47-
{{- toYaml . | nindent 12 }}
48-
{{- end }}
49-
{{- else if .Values.podAnnotations }}
50-
{{- with .Values.podAnnotations}}
51-
{{- toYaml . | nindent 12 }}
52-
{{- end }}
53-
{{- end }}
38+
{{- toYaml (merge (.Values.podAnnotations | default (dict)) (.Values.garbageCollect.podAnnotations | default (dict))) | nindent 12 }}
39+
{{- end}}
5440
spec:
5541
{{- if or (eq .Values.serviceAccount.create true) (ne .Values.serviceAccount.name "") }}
5642
serviceAccountName: {{ .Values.serviceAccount.name | default (include "docker-registry.fullname" .) }}
@@ -73,7 +59,10 @@ spec:
7359
- garbage-collect
7460
- --delete-untagged={{ .Values.garbageCollect.deleteUntagged }}
7561
- /etc/docker/registry/config.yml
76-
resources: {{ toYaml .Values.garbageCollect.resources | nindent 16 }}
62+
{{- if .Values.garbageCollect.resources }}
63+
resources:
64+
{{- toYaml .Values.garbageCollect.resources | nindent 16 }}
65+
{{- end }}
7766
env: {{ include "docker-registry.envs" . | nindent 16 }}
7867
{{- if .Values.containerSecurityContext.enabled }}
7968
securityContext: {{ omit .Values.containerSecurityContext "enabled" | toYaml | nindent 16 }}

0 commit comments

Comments
 (0)