From 1206673087c3e607fa3e5b5f92b78469a5b5afe5 Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Thu, 19 Dec 2024 10:30:25 +0100 Subject: [PATCH] Add flag to control config storage as secret (#12) --- charts/rclone-copy/templates/configmap.yaml | 4 ++++ charts/rclone-copy/templates/rclone-cron.yaml | 10 ++++++---- charts/rclone-copy/templates/secret.yaml | 4 ++++ charts/rclone-copy/values.yaml | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/charts/rclone-copy/templates/configmap.yaml b/charts/rclone-copy/templates/configmap.yaml index d516b7a..e857abe 100644 --- a/charts/rclone-copy/templates/configmap.yaml +++ b/charts/rclone-copy/templates/configmap.yaml @@ -3,5 +3,9 @@ kind: ConfigMap metadata: name: rclone-config-{{ .Release.Name }} data: + {{- if not .Values.secretConfig }} + rclone.conf: | +{{ .Values.rcloneConf | indent 4 }} + {{- end }} include-pattern.conf: | {{ .Values.includePattern | indent 4 }} diff --git a/charts/rclone-copy/templates/rclone-cron.yaml b/charts/rclone-copy/templates/rclone-cron.yaml index f546594..b2ebe7d 100644 --- a/charts/rclone-copy/templates/rclone-cron.yaml +++ b/charts/rclone-copy/templates/rclone-cron.yaml @@ -69,11 +69,11 @@ spec: rclone {{ .Values.command }} -v {{ .Values.arguments | join " " }} --include-from /root/include-pattern.conf "{{ include "rclone-copy.getSourceOrUrl" . }}" "{{ .Values.sync.dest.name }}:{{ .Values.sync.dest.path }}" volumeMounts: - - name: config + - name: {{ .Values.secretConfig | ternary "secret-config" "config" }} # This is the default path where the rclone implementation assumes the config is located mountPath: "/root/.config/rclone/rclone_ro.conf" subPath: "rclone.conf" - - name: include-config + - name: config mountPath: "/root/include-pattern.conf" subPath: "include-pattern.conf" @@ -100,10 +100,12 @@ spec: restartPolicy: {{ .Values.restartPolicy }} volumes: - - name: config + {{- if .Values.secretConfig }} + - name: secret-config secret: secretName: rclone-config-{{ .Release.Name }} - - name: include-config + {{- end }} + - name: config configMap: name: rclone-config-{{ .Release.Name }} backoffLimit: {{ .Values.backoffLimit }} diff --git a/charts/rclone-copy/templates/secret.yaml b/charts/rclone-copy/templates/secret.yaml index 1bc7839..ded72c1 100644 --- a/charts/rclone-copy/templates/secret.yaml +++ b/charts/rclone-copy/templates/secret.yaml @@ -1,3 +1,4 @@ +{{- if or .Values.configPassword .Values.secretConfig }} apiVersion: v1 kind: Secret metadata: @@ -7,4 +8,7 @@ data: {{- if .Values.configPassword }} password: {{ .Values.configPassword | b64enc }} {{- end }} + {{- if .Values.secretConfig }} rclone.conf: {{ .Values.rcloneConf | b64enc }} + {{- end }} +{{- end }} diff --git a/charts/rclone-copy/values.yaml b/charts/rclone-copy/values.yaml index aeb4ff3..1251608 100644 --- a/charts/rclone-copy/values.yaml +++ b/charts/rclone-copy/values.yaml @@ -90,3 +90,5 @@ secretRefs: {} # RCLONE_CONFIG_PASS: # name: secretName # key: secretKey + +secretConfig: true