From 6a3ad101450ff381890353014dde5aaf0562f137 Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Thu, 26 May 2022 20:51:59 +0200
Subject: [PATCH] feat: merge backup & forget cronjobs

---
 restic/Chart.yaml                             |  2 +-
 .../{cronjob_backup.yaml => cronjob.yaml}     | 20 +++++-
 restic/templates/cronjob_forget.yaml          | 63 -------------------
 3 files changed, 19 insertions(+), 66 deletions(-)
 rename restic/templates/{cronjob_backup.yaml => cronjob.yaml} (73%)
 delete mode 100644 restic/templates/cronjob_forget.yaml

diff --git a/restic/Chart.yaml b/restic/Chart.yaml
index 7fef456..7e4b93b 100644
--- a/restic/Chart.yaml
+++ b/restic/Chart.yaml
@@ -2,5 +2,5 @@ apiVersion: v2
 name: restic
 description: Helm Chart for restic
 type: application
-version: 1.0.1
+version: 1.0.2
 appVersion: "0.13.1"
diff --git a/restic/templates/cronjob_backup.yaml b/restic/templates/cronjob.yaml
similarity index 73%
rename from restic/templates/cronjob_backup.yaml
rename to restic/templates/cronjob.yaml
index f2b75a8..950d0de 100644
--- a/restic/templates/cronjob_backup.yaml
+++ b/restic/templates/cronjob.yaml
@@ -1,7 +1,7 @@
 apiVersion: batch/v1
 kind: CronJob
 metadata:
-  name: {{ include "restic-helm.fullname" . }}-backup
+  name: {{ include "restic-helm.fullname" . }}
   labels:
     {{- include "restic-helm.labels" . | nindent 4 }}
 spec:
@@ -35,7 +35,7 @@ spec:
             - name: data
               {{- .Values.volume | nindent 14 }}
           containers:
-            - name: {{ .Chart.Name }}
+            - name: backup
               securityContext:
                 {{- toYaml .Values.securityContext | nindent 16 }}
               image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
@@ -54,6 +54,22 @@ spec:
               volumeMounts:
                 - mountPath: "/sync"
                   name: data
+            - name: forget
+              securityContext:
+                {{- toYaml .Values.securityContext | nindent 16 }}
+              image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+              imagePullPolicy: {{ .Values.image.pullPolicy }}
+              args:
+                - "-r"
+                - "{{ .Values.repository.name }}"
+                - "forget"
+                - "--prune"
+                {{- toYaml .Values.keepOptions | nindent 16 }}
+              envFrom:
+                - secretRef:
+                    name: {{ include "restic-helm.fullname" . }}
+              resources:
+                {{- toYaml .Values.resources | nindent 16 }}
           {{- with .Values.nodeSelector }}
           nodeSelector:
             {{- toYaml . | nindent 12 }}
diff --git a/restic/templates/cronjob_forget.yaml b/restic/templates/cronjob_forget.yaml
deleted file mode 100644
index 953113b..0000000
--- a/restic/templates/cronjob_forget.yaml
+++ /dev/null
@@ -1,63 +0,0 @@
-apiVersion: batch/v1
-kind: CronJob
-metadata:
-  name: {{ include "restic-helm.fullname" . }}-forget
-  labels:
-    {{- include "restic-helm.labels" . | nindent 4 }}
-spec:
-  schedule: "{{ .Values.schedule }}"
-  jobTemplate:
-    metadata:
-      {{- with .Values.jobAnnotations }}
-      annotations:
-        {{- toYaml . | nindent 8 }}
-      {{- end }}
-      labels:
-        {{- include "restic-helm.labels" . | nindent 8 }}
-    spec:
-      template:
-        metadata:
-          {{- with .Values.podAnnotations }}
-          annotations:
-            {{- toYaml . | nindent 12 }}
-          {{- end }}
-          labels:
-            {{- include "restic-helm.labels" . | nindent 12 }}
-        spec:
-          restartPolicy: OnFailure
-          {{- with .Values.imagePullSecrets }}
-          imagePullSecrets:
-            {{- toYaml . | nindent 12 }}
-          {{- end }}
-          securityContext:
-            {{- toYaml .Values.podSecurityContext | nindent 12 }}
-          containers:
-            - name: {{ .Chart.Name }}
-              securityContext:
-                {{- toYaml .Values.securityContext | nindent 16 }}
-              image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
-              imagePullPolicy: {{ .Values.image.pullPolicy }}
-              workingDir: "/sync"
-              args:
-                - "-r"
-                - "{{ .Values.repository.name }}"
-                - "forget"
-                - "--prune"
-                {{- toYaml .Values.keepOptions | nindent 16 }}
-              envFrom:
-                - secretRef:
-                    name: {{ include "restic-helm.fullname" . }}
-              resources:
-                {{- toYaml .Values.resources | nindent 16 }}
-          {{- with .Values.nodeSelector }}
-          nodeSelector:
-            {{- toYaml . | nindent 12 }}
-          {{- end }}
-          {{- with .Values.affinity }}
-          affinity:
-            {{- toYaml . | nindent 12 }}
-          {{- end }}
-          {{- with .Values.tolerations }}
-          tolerations:
-            {{- toYaml . | nindent 12 }}
-          {{- end }}
-- 
GitLab