{{- if .Values.ingressRoute.dashboard.enabled -}}
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: {{ template "traefik.fullname" . }}-dashboard
  namespace: {{ template "traefik.namespace" . }}
  annotations:
    {{- with .Values.ingressRoute.dashboard.annotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  labels:
    {{- include "traefik.labels" . | nindent 4 }}
    {{- with .Values.ingressRoute.dashboard.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  entryPoints:
  {{- range .Values.ingressRoute.dashboard.entryPoints }}
  - {{ . }}
  {{- end }}
  routes:
  - match: {{ .Values.ingressRoute.dashboard.matchRule }}
    kind: Rule
    services:
    - name: api@internal
      kind: TraefikService
    {{- with .Values.ingressRoute.dashboard.middlewares }}
    middlewares:
      {{- toYaml . | nindent 6 }}
    {{- end -}}

  {{- with .Values.ingressRoute.dashboard.tls }}
  tls:
    {{- toYaml . | nindent 4 }}
  {{- end }}
{{- end -}}
