{{- if and .Values.services.http.enabled .Values.ingress.enabled }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  {{- with (include "prometheus-fail2ban-exporter.ingress.annotations" . | fromYaml) }}
  annotations:
    {{- tpl (. | toYaml) $ | nindent 4 }}
  {{- end }}
  {{- with (include "prometheus-fail2ban-exporter.ingress.labels" . | fromYaml) }}
  labels:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  name: {{ include "prometheus-fail2ban-exporter.fullname" . }}
  namespace: {{ .Release.Namespace }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  rules:
  {{- range .Values.ingress.hosts }}
  - host: {{ tpl .host $ | quote }}
    http:
      paths:
      {{- range .paths }}
      - path: {{ .path }}
        {{- if .pathType }}
        pathType: {{ .pathType }}
        {{- end }}
        backend:
          service:
            name: {{ include "prometheus-fail2ban-exporter.fullname" $ }}
            port:
              number: {{ $.Values.services.http.port }}
      {{- end }}
  {{- end }}
  {{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
  - hosts:
    {{- range .hosts }}
    - {{ tpl . $ | quote }}
    {{- end }}
    secretName: {{ .secretName | quote }}
  {{- end }}
{{- end }}
{{- end }}