{{- if not .Values.secrets.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "fuellhorn.fullname" . }}-secrets
  labels:
    {{- include "fuellhorn.labels" . | nindent 4 }}
type: Opaque
data:
  secret-key: {{ .Values.secrets.secretKey | b64enc | quote }}
  fuellhorn-secret: {{ .Values.secrets.fuellhornSecret | b64enc | quote }}
{{- end }}
---
{{- if eq .Values.database.type "postgresql" }}
{{- if not .Values.database.external.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "fuellhorn.fullname" . }}-db
  labels:
    {{- include "fuellhorn.labels" . | nindent 4 }}
type: Opaque
data:
  password: {{ .Values.database.external.password | b64enc | quote }}
  url: {{ printf "postgresql://%s:%s@%s:%d/%s" .Values.database.external.username .Values.database.external.password .Values.database.external.host (int .Values.database.external.port) .Values.database.external.database | b64enc | quote }}
{{- end }}
{{- end }}
