From 933f0b6bac54d7b69a8ccd920be45c0b6932bae6 Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Thu, 26 May 2022 21:02:53 +0200
Subject: [PATCH] fix: correct issue with cronjob container ordering

---
 restic/templates/cronjob.yaml | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/restic/templates/cronjob.yaml b/restic/templates/cronjob.yaml
index 950d0de..1924551 100644
--- a/restic/templates/cronjob.yaml
+++ b/restic/templates/cronjob.yaml
@@ -34,42 +34,43 @@ spec:
           volumes:
             - name: data
               {{- .Values.volume | nindent 14 }}
-          containers:
-            - name: backup
+          initContainers:
+            - name: forget
               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 }}"
-                - "backup"
-                - "."
+                - "forget"
+                - "--prune"
+                {{- toYaml .Values.keepOptions | nindent 16 }}
               envFrom:
                 - secretRef:
                     name: {{ include "restic-helm.fullname" . }}
               resources:
                 {{- toYaml .Values.resources | nindent 16 }}
-              volumeMounts:
-                - mountPath: "/sync"
-                  name: data
-            - name: forget
+          containers:
+            - name: backup
               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 }}
+                - "backup"
+                - "."
               envFrom:
                 - secretRef:
                     name: {{ include "restic-helm.fullname" . }}
               resources:
                 {{- toYaml .Values.resources | nindent 16 }}
+              volumeMounts:
+                - mountPath: "/sync"
+                  name: data
           {{- with .Values.nodeSelector }}
           nodeSelector:
             {{- toYaml . | nindent 12 }}
-- 
GitLab