{{ if not .Values.existingOpenIdSecret }}
{{- $openIdKey := (genPrivateKey "rsa") | b64enc | quote }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "defguard.openidSecretName" .)) }}
{{- if $secret }}
{{- $openIdKey = index $secret.data "openid-key" }}
{{- end }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "defguard.openidSecretName" . }}
  labels:
    {{- include "defguard.labels" . | nindent 4 }}
type: Opaque
data:
  openid-key: {{ $openIdKey }}
{{- end }}
