From d746a522dcaacb534de2778e9ccef44f14887468 Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Wed, 11 May 2022 18:30:10 +0200
Subject: [PATCH] feat: improve redis support

---
 oauth2-proxy/templates/deployment.yaml | 16 +++++++++++-----
 oauth2-proxy/templates/secret.yaml     |  3 +++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/oauth2-proxy/templates/deployment.yaml b/oauth2-proxy/templates/deployment.yaml
index 13d67cb..590c3b4 100644
--- a/oauth2-proxy/templates/deployment.yaml
+++ b/oauth2-proxy/templates/deployment.yaml
@@ -34,18 +34,27 @@ spec:
             - name: OAUTH2_PROXY_CLIENT_ID
               valueFrom:
                 secretKeyRef:
-                  key: client-id
                   name: {{ include "oauth2-proxy-helm.fullname" . }}
+                  key: client-id
             - name: OAUTH2_PROXY_CLIENT_SECRET
               valueFrom:
                 secretKeyRef:
-                  key: client-secret
                   name: {{ include "oauth2-proxy-helm.fullname" . }}
+                  key: client-secret
             - name: OAUTH2_PROXY_COOKIE_SECRET
               valueFrom:
                 secretKeyRef:
+                  name: {{ include "oauth2-proxy-helm.fullname" . }}
                   key: cookie-secret
+            {{ if .Values.redis.enabled }}
+            {{ if ne .Values.redis.password "" }}
+            - name: OAUTH2_PROXY_REDIS_PASSWORD
+              valueFrom:
+                secretKeyRef:
                   name: {{ include "oauth2-proxy-helm.fullname" . }}
+                  key: redis-password
+            {{ end }}
+            {{ end }}
           args:
             {{ range .Values.auth.roles }}
             - "--allowed-role={{ . }}"
@@ -58,9 +67,6 @@ spec:
             - "--provider=oidc"
             {{ if .Values.redis.enabled }}
             - "--redis-connection-url=redis://{{ .Values.redis.host }}/{{ .Values.redis.database }}"
-            {{ if .Values.redis.password ne "" }}
-            - "--redis-password={{ .Values.redis.password }}"
-            {{ end }}
             {{ end }}
           ports:
             - name: http
diff --git a/oauth2-proxy/templates/secret.yaml b/oauth2-proxy/templates/secret.yaml
index 33983b2..cb69f7c 100644
--- a/oauth2-proxy/templates/secret.yaml
+++ b/oauth2-proxy/templates/secret.yaml
@@ -8,3 +8,6 @@ stringData:
   client-id: "{{ .Values.oidc.clientId }}"
   client-secret: "{{ .Values.oidc.clientSecret }}"
   cookie-secret: "{{ .Values.cookieSecret }}"
+  {{ if .Values.redis.enabled }}
+  redis-password: "{{ .Values.redis.password }}"
+  {{ end }}
-- 
GitLab