{{- if eq .Values.postgresql.mode "integrated" }}
{{- $password := default (randAlphaNum 16) .Values.postgresql.integrated.auth.password }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "groombook.fullname" . }}-db-credentials
  labels:
    {{- include "groombook.labels" . | nindent 4 }}
type: Opaque
stringData:
  postgresql-password: {{ $password | quote }}
  database-url: {{ printf "postgres://%s:%s@%s-postgresql:5432/%s" .Values.postgresql.integrated.auth.username $password (include "groombook.fullname" .) .Values.postgresql.integrated.auth.database | quote }}
{{- end }}
