Skip to content

Commit

Permalink
chart: add existing opeind secret functionality (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
filiprafaj authored Jul 12, 2024
1 parent d505896 commit 499e401
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions charts/defguard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Define opeind secret name
*/}}
{{- define "defguard.openidSecretName" -}}
{{- $name := "openid-key" }}
{{- $name }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/defguard/templates/defguard-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ spec:
volumes:
- name: openid-key
secret:
secretName: {{ .Values.openIdKey }}
secretName: {{ .Values.existingOpenIdSecret | default (include "defguard.openidSecretName" .) }}
optional: false
6 changes: 4 additions & 2 deletions charts/defguard/templates/openid-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{{ if not .Values.existingOpenIdSecret }}
{{- $openIdKey := (genPrivateKey "rsa") | b64enc | quote }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace .Values.openIdKey) }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "defguard.openidSecretName" .)) }}
{{- if $secret }}
{{- $openIdKey = index $secret.data "openid-key" }}
{{- end }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.openIdKey }}
name: {{ include "defguard.openidSecretName" . }}
labels:
{{- include "defguard.labels" . | nindent 4 }}
type: Opaque
data:
openid-key: {{ $openIdKey }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/defguard/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ldap:
user_search_base: ""
nameOverride: ""
nodeSelector: {}
openIdKey: openid-key
existingOpenIdSecret: ""
podAnnotations: {}
podLabels: {}
podSecurityContext: {}
Expand Down

0 comments on commit 499e401

Please sign in to comment.