{{- if not .Values.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "mongo-express.secretName" . }}
  labels:
    {{- include "mongo-express.labels" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations:
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  {{- if .Values.mongodbEnableAdmin }}
  mongodb-admin-password: {{ .Values.mongodbAdminPassword | b64enc | quote }}
  {{- else }}
  mongodb-auth-password: {{ .Values.mongodbAuthPassword | b64enc | quote }}
  {{- end }}
  site-cookie-secret: {{ default (randAlphaNum 32) .Values.siteCookieSecret | b64enc | quote }}
  site-session-secret: {{ default (randAlphaNum 32) .Values.siteSessionSecret | b64enc | quote }}
  {{- if and .Values.basicAuthUsername .Values.basicAuthPassword }}
  basic-auth-password: {{ .Values.basicAuthPassword | b64enc | quote }}
  {{- end }}
{{- end }}
