{{- if .Values.createAdminSecret -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "couchdb.fullname" . }}
  labels:
    app: {{ template "couchdb.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
type: Opaque
data:
  adminUsername: {{ template "couchdb.defaultsecret" .Values.adminUsername }}
  adminPassword: {{ template "couchdb.defaultsecret" .Values.adminPassword }}
  {{- $erlangCookieArgs := dict "key" "erlangCookie" "ns" $.Release.Namespace "secretName" (include "couchdb.fullname" .) "secret" .Values.erlangFlags.setcookie }}
  erlangCookie: {{ template "couchdb.defaultsecret-stateful" $erlangCookieArgs }}
  cookieAuthSecret: {{ template "couchdb.defaultsecret" .Values.cookieAuthSecret }}
{{- if  .Values.adminHash  }}
  adminHash: {{ .Values.adminHash | b64enc | quote }}
{{- end -}}
{{- end -}}
