{{- if .Values.route.enabled -}}
apiVersion: {{ .Values.route.apiVersion}}
kind: {{ .Values.route.kind}}
metadata:
  name: {{ template "databasus.fullname" . }}
  annotations: {{ toYaml .Values.route.annotations | nindent 4 }}
  labels:
    app.kubernetes.io/component: "app"
    {{- include "databasus.labels" . | nindent 4 }}
spec:
  {{- with .Values.route.parentRefs }}
  parentRefs:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- with .Values.route.hostnames }}
  hostnames:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  rules:
    - backendRefs:
        - name: {{ template "databasus.fullname" . }}-service
          port: {{ .Values.service.port }}
      {{- with .Values.route.filters }}
      filters:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.route.matches }}
      matches:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.route.timeouts }}
      timeouts:
        {{- toYaml . | nindent 8 }}
      {{- end }}
  {{- end }}