{{ if not .Values.existingJwtSecret }}
{{- $auth := (randAlpha 16) | b64enc | quote }}
{{- $gateway := (randAlpha 16) | b64enc | quote }}
{{- $yubiBridge := (randAlpha 16) | b64enc | quote }}
{{- $secretKey := (randAlpha 64) | b64enc | quote }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "defguard.jwtSecretName" .)) }}
{{- if $secret }}
{{- $auth = index $secret.data "auth" }}
{{- $gateway = index $secret.data "gateway" }}
{{- $yubiBridge = index $secret.data "yubi-bridge" }}
{{- $secretKey = index $secret.data "secret-key" }}
{{- end }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "defguard.jwtSecretName" . }}
  labels:
    {{- include "defguard.labels" . | nindent 4 }}
type: Opaque
data:
  auth: {{ $auth }}
  gateway: {{ $gateway }}
  yubi-bridge: {{ $yubiBridge }}
  secret-key: {{ $secretKey }}
{{- end }}
