{{- if or .Values.ui.ingress.enabled .Values.ingestion.ingress.enabled }}
{{- $serviceName := include "seq.fullname" . -}}
apiVersion: {{ template "ingress.apiVersion" . }}
kind: Ingress
metadata:
  name: {{ $serviceName }}
  labels:
    app: {{ template "seq.name" . }}
    chart: {{ template "seq.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- if .Values.ingress.labels }}
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . | quote }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  {{ if .Values.ui.ingress.enabled }}
  {{- $uiPath := .Values.ui.ingress.path -}}
  {{- $uiPort := .Values.ui.service.port -}}
  {{- range .Values.ui.ingress.hosts }}
    - host: {{ . }}
      http:
        paths:
          - path: {{ $uiPath }}
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $uiPort }}
  {{- end }}
  {{- end }}
  {{ if .Values.ingestion.ingress.enabled }}
  {{- $ingestionPath := .Values.ingestion.ingress.path -}}
  {{- $ingestionPort := .Values.ingestion.service.port -}}
  {{- range .Values.ingestion.ingress.hosts }}
    - host: {{ . }}
      http:
        paths:
          - path: {{ $ingestionPath }}
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $ingestionPort }}
  {{- end }}
  {{- end }}
{{- end }}
