Skip to content

Commit

Permalink
restore helper
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Aug 7, 2024
1 parent faa7b39 commit 038fa66
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
18 changes: 18 additions & 0 deletions charts/cryostat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ Get or generate a default secret key for object storage.
{{- end -}}
{{- end -}}

{{/*
Get or generate a default secret key for auth proxy cookies.
*/}}
{{- define "cryostat.cookieSecret" -}}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (printf "%s-cookie-secret" .Release.Name)) -}}
{{- if $secret -}}
{{/*
Use current secret. Do not regenerate.
*/}}
{{- $secret.data.COOKIE_SECRET -}}
{{- else -}}
{{/*
Generate new secret
*/}}
{{- (randAlphaNum 32) | b64enc | quote -}}
{{- end -}}
{{- end -}}

{{/*
Get sanitized list or defaults (if not disabled) as comma-separated list.
*/}}
Expand Down
8 changes: 1 addition & 7 deletions charts/cryostat/templates/cookie_secret.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (printf "%s-cookie-secret" .Release.Name)) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-cookie-secret
type: Opaque
{{ if $secret -}}
data:
COOKIE_SECRET: {{ $secret.data.COOKIE_SECRET }}
{{ else -}}
stringData:
COOKIE_SECRET: {{ randAlphaNum 32 }}
{{ end }}
COOKIE_SECRET: {{ include "cryostat.cookieSecret" . }}
2 changes: 1 addition & 1 deletion charts/cryostat/tests/cookie_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ tests:
path: type
value: Opaque
- exists:
path: stringData.COOKIE_SECRET
path: data.COOKIE_SECRET

0 comments on commit 038fa66

Please sign in to comment.