{{- if not .Values.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "hindsight.secretName" . }}
  labels:
    {{- include "hindsight.labels" . | nindent 4 }}
type: Opaque
data:
  {{- range $key, $value := .Values.api.secrets }}
  {{ $key }}: {{ $value | b64enc | quote }}
  {{- end }}
  {{- range $key, $value := .Values.controlPlane.secrets }}
  {{ $key }}: {{ $value | b64enc | quote }}
  {{- end }}
  {{- if and (not .Values.postgresql.enabled) .Values.postgresql.external.password }}
  postgres-password: {{ .Values.postgresql.external.password | b64enc | quote }}
  {{- end }}
{{- end }}
