Skip to content

Commit fbbf028

Browse files
committed
feat(config): add 'tpl' usage for alphaConfig.existingSecret, alphaConfig.existingConfig, config.existingConfig, podAnnotations and podLabels
Signed-off-by: kilianpaquier <git@kilianpaquier.dev>
1 parent fe328b0 commit fbbf028

8 files changed

Lines changed: 88 additions & 8 deletions

helm/oauth2-proxy/Chart.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: oauth2-proxy
2-
version: 10.7.0
2+
version: 10.9.0
33
apiVersion: v2
44
appVersion: 7.15.3
55
home: https://oauth2-proxy.github.io/oauth2-proxy/
@@ -40,3 +40,8 @@ annotations:
4040
links:
4141
- name: GitHub PR
4242
url: https://github.com/oauth2-proxy/manifests/pull/405
43+
- kind: added
44+
description: Add 'tpl' usage for alphaConfig.existingSecret, alphaConfig.existingConfig, config.existingConfig, podAnnotations and podLabels
45+
links:
46+
- name: GitHub PR
47+
url: https://github.com/oauth2-proxy/manifests/pull/418
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Test Case: alphaConfig enabled + existingSecret TPL
2+
# Expected: Chart mounts the external alpha Secret instead of generating one.
3+
4+
tplValue: prefix
5+
6+
alphaConfig:
7+
enabled: true
8+
existingSecret: '{{ .Values.tplValue }}-alpha-secret'
9+
10+
extraObjects:
11+
- apiVersion: v1
12+
kind: Secret
13+
metadata:
14+
name: '{{ .Values.tplValue }}-alpha-secret'
15+
type: Opaque
16+
stringData:
17+
oauth2_proxy.yml: |
18+
---
19+
server:
20+
BindAddress: 0.0.0.0:4180
21+
providers:
22+
- id: google
23+
provider: google
24+
clientID: fake-client-id
25+
clientSecret: fake-client-secret
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Test Case: config + existingConfig TPL
2+
# Expected: Chart mounts the external config ConfigMap instead of generating one.
3+
4+
tplValue: prefix
5+
6+
config:
7+
existingConfig: '{{ .Values.tplValue }}-config'
8+
9+
extraObjects:
10+
- apiVersion: v1
11+
kind: ConfigMap
12+
metadata:
13+
name: '{{ .Values.tplValue }}-config'
14+
data:
15+
oauth2_proxy.cfg: |
16+
email_domains = [ "*" ]
17+
upstreams = [ "file:///dev/null" ]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Test Case: config + existingSecret TPL
2+
# Expected: Chart mounts the external Secret instead of generating one.
3+
4+
tplValue: prefix
5+
6+
config:
7+
existingSecret: '{{ .Values.tplValue }}-secret'
8+
9+
extraObjects:
10+
- apiVersion: v1
11+
kind: Secret
12+
metadata:
13+
name: '{{ .Values.tplValue }}-secret'
14+
type: Opaque
15+
stringData:
16+
client-id: fake-client-id
17+
client-secret: fake-client-secret
18+
cookie-secret: fake-cookie-secret-of-24

helm/oauth2-proxy/ci/tpl-values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ deploymentLabels:
6363
deploymentAnnotations:
6464
test-annotations/test: "{{ $.Release.Name }}"
6565

66+
podAnnotations:
67+
test-annotations/test: "{{ $.Release.Name }}"
68+
69+
podLabels:
70+
test-pod-label/test: "{{ $.Release.Name }}"
71+
6672
autoscaling:
6773
annotations:
6874
test-annotations/test: "{{ $.Release.Name }}"

helm/oauth2-proxy/templates/_helpers.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ generated
185185
{{- define "oauth2-proxy.alpha-config.name" -}}
186186
{{- $source := include "oauth2-proxy.alpha-config.source" . -}}
187187
{{- if eq $source "existing-configmap" -}}
188-
{{- .Values.alphaConfig.existingConfig -}}
188+
{{- printf "%s" (tpl .Values.alphaConfig.existingConfig $) -}}
189189
{{- else if eq $source "existing-secret" -}}
190-
{{- .Values.alphaConfig.existingSecret -}}
190+
{{- printf "%s" (tpl .Values.alphaConfig.existingSecret $) -}}
191191
{{- else if eq $source "generated" -}}
192192
{{- printf "%s-alpha" (include "oauth2-proxy.fullname" .) | trunc 63 | trimSuffix "-" -}}
193193
{{- end -}}
@@ -226,7 +226,7 @@ generated-legacy
226226

227227
{{- define "oauth2-proxy.legacy-config.name" -}}
228228
{{- if eq (include "oauth2-proxy.legacy-config.mode" .) "existing-configmap" -}}
229-
{{- .Values.config.existingConfig -}}
229+
{{- printf "%s" (tpl .Values.config.existingConfig $) -}}
230230
{{- else -}}
231231
{{- template "oauth2-proxy.fullname" . -}}
232232
{{- end -}}

helm/oauth2-proxy/templates/deployment.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ spec:
4747
{{- if .Values.htpasswdFile.enabled }}
4848
checksum/htpasswd: {{ toYaml .Values.htpasswdFile.entries | sha256sum }}
4949
{{- end }}
50-
{{- if .Values.podAnnotations }}
51-
{{ toYaml .Values.podAnnotations | indent 8 }}
50+
{{- with .Values.podAnnotations }}
51+
{{ tpl ( toYaml . ) $ | indent 8 }}
5252
{{- end }}
5353
labels:
5454
app: {{ template "oauth2-proxy.name" . }}
5555
{{- include "oauth2-proxy.labels" . | indent 8 }}
56-
{{- if .Values.podLabels }}
57-
{{ toYaml .Values.podLabels | indent 8 }}
56+
{{- with .Values.podLabels }}
57+
{{ tpl ( toYaml . ) $ | indent 8 }}
5858
{{- end }}
5959
spec:
6060
{{- if .Values.priorityClassName }}

helm/oauth2-proxy/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ config:
2323
clientID: "XXXXXXX"
2424
# OAuth client secret
2525
clientSecret: "XXXXXXXX"
26+
# Custom secret name instead of generating one with 'clientID', 'clientSecret' and 'cookieSecret'.
27+
# Secret keys must be the one provided with 'requiredSecretKeys' below.
28+
# Mutually exclusive with 'clientID', 'clientSecret' and 'cookieSecret'.
29+
# Supports Helm templating, e.g. '{{ .Release.Name }}-secret' or '{{ include "myapp.oauth2-proxy.secretName" . }}'
30+
existingSecret: ~
2631
# List of secret keys to include in the secret and expose as environment variables.
2732
# By default, all three secrets are required. To exclude certain secrets
2833
# (e.g., when using federated token authentication), remove them from this list.
@@ -135,8 +140,10 @@ config:
135140
# Use an existing config map (see configmap.yaml for required fields)
136141
# This is ignored when alphaConfig.enabled=true and
137142
# forceLegacyConfig=false.
143+
# Supports Helm templating, e.g. '{{ .Release.Name }}-config' or '{{ include "myapp.oauth2-proxy.configName" . }}'
138144
# Example:
139145
# existingConfig: config
146+
# existingConfig: '{{ .Release.Name }}-config'
140147
existingConfig: ~
141148

142149
alphaConfig:
@@ -182,10 +189,12 @@ alphaConfig:
182189
# Use an existing config map (see secret-alpha.yaml for required fields).
183190
# Mutually exclusive with existingSecret and all generated alpha config
184191
# content options (serverConfigData, metricsConfigData, configData, configFile).
192+
# Supports Helm templating, e.g. '{{ .Release.Name }}-config' or '{{ include "myapp.oauth2-proxy.configName" . }}'
185193
existingConfig: ~
186194
# Use an existing secret.
187195
# Mutually exclusive with existingConfig and all generated alpha config
188196
# content options (serverConfigData, metricsConfigData, configData, configFile).
197+
# Supports Helm templating, e.g. '{{ .Release.Name }}-secret' or '{{ include "myapp.oauth2-proxy.secretName" . }}'
189198
existingSecret: ~
190199
#
191200
# NOTE: When using alphaConfig with external secrets (e.g., Azure

0 commit comments

Comments
 (0)