{{- if or (not .Values.auth.existingErlangSecret) (not .Values.auth.existingPasswordSecret) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "rabbitmq.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
type: Opaque
data:
  {{- if not .Values.auth.existingPasswordSecret }}
  {{- if .Values.auth.password }}
  rabbitmq-password: {{ .Values.auth.password | b64enc | quote }}
  {{- else }}
  rabbitmq-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
  {{- if not .Values.auth.existingErlangSecret }}
  {{- if .Values.auth.erlangCookie }}
  rabbitmq-erlang-cookie: {{ .Values.auth.erlangCookie | b64enc | quote }}
  {{- else }}
  rabbitmq-erlang-cookie: {{ randAlphaNum 32 | b64enc | quote }}
  {{- end }}
  {{- end }}
{{- end }}
{{- range $key, $value := .Values.extraSecrets }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ $key }}
  namespace: {{ $.Release.Namespace }}
  labels: {{- include "common.labels.standard" $ | nindent 4 }}
type: Opaque
stringData: {{- $value | toYaml | nindent 2 }}
{{- end }}
