{{- if and (not .Values.supersync.existingSecret) (eq .Values.supersync.secret.jwtSecret "") }}
  {{- fail "supersync.secret.jwtSecret is required (min 32 chars) when supersync.existingSecret is not set" }}
{{- end }}
{{- if not .Values.supersync.existingSecret -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "supersync.fullname" . }}
  labels:
    {{- include "supersync.labels" . | nindent 4 }}
type: Opaque
stringData:
  JWT_SECRET: {{ .Values.supersync.secret.jwtSecret | quote }}
  {{- if and .Values.supersync.smtp.enabled (not .Values.supersync.smtp.existingSecret) }}
  SMTP_USER: {{ .Values.supersync.smtp.user | quote }}
  SMTP_PASS: {{ .Values.supersync.smtp.password | quote }}
  {{- end }}
{{- end }}
