Skip to content

Commit 670f4b5

Browse files
committed
use common.names.fullname to get the redis chart
Signed-off-by: Nico Braun <[email protected]>
1 parent 1a5a007 commit 670f4b5

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

helm/oauth2-proxy/templates/_helpers.tpl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,26 @@ Create the name of the service account to use
7878
{{- end -}}
7979
{{- end -}}
8080

81+
{{/*
82+
Redis subcharts fullname
83+
*/}}
84+
{{- define "oauth2-proxy.redis.fullname" -}}
85+
{{- if .Values.redis.enabled -}}
86+
{{- include "common.names.fullname" (dict "Chart" (dict "Name" "redis") "Release" .Release "Values" .Values.redis) -}}
87+
{{- else -}}
88+
{{ fail "attempting to use redis subcharts fullname, even though the subchart is not enabled. This will lead to misconfiguration" }}
89+
{{- end -}}
90+
{{- end -}}
91+
8192
{{/*
8293
Compute the redis url if not set explicitly.
8394
*/}}
84-
{{- define "oauth2-proxy.redisStandaloneUrl" -}}
85-
{{- $masterPort := .Values.redis.master.service.ports.redis -}}
95+
{{- define "oauth2-proxy.redis.StandaloneUrl" -}}
8696
{{- if .Values.sessionStorage.redis.standalone.connectionUrl -}}
8797
{{ .Values.sessionStorage.redis.standalone.connectionUrl }}
88-
{{- else if .Values.redis.fullnameOverride -}}
89-
{{- printf "redis://%s-master:%.0f" (.Values.redis.fullnameOverride | trunc 63 | trimSuffix "-") $masterPort -}}
90-
{{- else -}}
91-
{{- $name := default "redis" .Values.redis.nameOverride -}}
92-
{{- if contains $name .Release.Name -}}
93-
{{- printf "redis://%s-master:%.0f" (.Release.Name | trunc 63 | trimSuffix "-") $masterPort -}}
98+
{{- else if .Values.redis.enabled -}}
99+
{{- printf "redis://%s-master:%.0f" (include "oauth2-proxy.redis.fullname" .) .Values.redis.master.service.ports.redis -}}
94100
{{- else -}}
95-
{{- printf "redis://%s-master:%.0f" (printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-") $masterPort -}}
96-
{{- end -}}
101+
{{ fail "please set sessionStorage.redis.standalone.connectionUrl or enable the redis subchart via redis.enabled" }}
97102
{{- end -}}
98103
{{- end -}}

helm/oauth2-proxy/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ spec:
117117
{{- end }}
118118
{{- if eq (default "" .Values.sessionStorage.redis.clientType) "standalone" }}
119119
- name: OAUTH2_PROXY_REDIS_CONNECTION_URL
120-
value: {{ include "oauth2-proxy.redisStandaloneUrl" . }}
120+
value: {{ include "oauth2-proxy.redis.StandaloneUrl" . }}
121121
{{- else if eq (default "" .Values.sessionStorage.redis.clientType) "cluster" }}
122122
- name: OAUTH2_PROXY_REDIS_USE_CLUSTER
123123
value: "true"

0 commit comments

Comments
 (0)