{{- if (include "mongodb.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "mongodb.fullname" . }}
  namespace: {{ template "mongodb.namespace" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: mongodb
type: Opaque
data:
  {{- if .Values.auth.rootPassword }}
  mongodb-root-password:  {{ .Values.auth.rootPassword | b64enc | quote }}
  {{- else }}
  mongodb-root-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- if and .Values.auth.username .Values.auth.database }}
  {{- if .Values.auth.password }}
  mongodb-password:  {{ .Values.auth.password | b64enc | quote }}
  {{- else }}
  mongodb-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
  {{- if eq .Values.architecture "replicaset" }}
  {{- if .Values.auth.replicaSetKey }}
  mongodb-replica-set-key:  {{ .Values.auth.replicaSetKey | b64enc | quote }}
  {{- else }}
  mongodb-replica-set-key: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
{{- end }}
