{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: {{ include "airflow.fullname" . }}-web
  {{- if .Values.ingress.web.annotations }}
  annotations:
    {{- toYaml .Values.ingress.web.annotations | nindent 4 }}
  {{- end }}
  labels:
    app: {{ include "airflow.labels.app" . }}
    component: web
    chart: {{ include "airflow.labels.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    {{- if .Values.ingress.web.labels }}
    {{- toYaml .Values.ingress.web.labels | nindent 4 }}
    {{- end }}
spec:
  {{- if .Values.ingress.web.tls.enabled }}
  tls:
    - hosts:
        - {{ .Values.ingress.web.host }}
      secretName: {{ .Values.ingress.web.tls.secretName }}
  {{- end }}
  rules:
    - http:
        paths:
          {{- range .Values.ingress.web.precedingPaths }}
          - path: {{ .path }}
            backend:
              serviceName: {{ .serviceName }}
              servicePort: {{ .servicePort }}
          {{- end }}
          - path: {{ .Values.ingress.web.path }}
            backend:
              serviceName: {{ include "airflow.fullname" . }}-web
              servicePort: web
          {{- range .Values.ingress.web.succeedingPaths }}
          - path: {{ .path }}
            backend:
              serviceName: {{ .serviceName }}
              servicePort: {{ .servicePort }}
          {{- end }}
      host: {{ .Values.ingress.web.host }}
{{- end }}
