---
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "rocketchat.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "rocketchat.name" . }}
    helm.sh/chart: {{ include "rocketchat.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
type: Opaque
data:
{{- if .Values.registrationToken }}
  reg-token: {{ .Values.registrationToken | b64enc | quote }}
{{ end }}
{{- if .Values.license }}
  license: {{ .Values.license | b64enc | quote }}
{{ end }}
{{- if .Values.smtp.enabled }}
{{- if not .Values.smtp.existingSecret}}
  mail-url: {{ printf "smtp://%s:%s@%s:%.0f" .Values.smtp.username .Values.smtp.password .Values.smtp.host .Values.smtp.port | b64enc | quote }}
{{- end }}
{{- end }}
{{- if not .Values.existingMongodbSecret }}
  mongo-uri: {{ include "rocketchat.mongodb.url" . | b64enc | quote }}
  mongo-oplog-uri: {{ include "rocketchat.mongodb.oplogUrl" . | b64enc | quote }}
{{- end }}