{{- if .Values.webdav.ingress.enabled -}}
{{- $serviceName := include "koodo-reader.fullname" . -}}
{{- $servicePort := .Values.webdav.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "koodo-reader.fullname" . }}-webdav
  labels:
    {{- include "koodo-reader.labels" . | nindent 4 }}
  annotations:
    {{- range $key, $value := .Values.webdav.ingress.annotations }}
      {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  {{- if .Values.webdav.ingress.className }}
  ingressClassName: {{ .Values.webdav.ingress.className }}
  {{- end }}
  rules:
    {{- range $host := .Values.webdav.ingress.hosts }}
    - host: {{ $host }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: {{ $serviceName }}
                port:
                  number: {{ $servicePort }}
    {{- end -}}
  {{- if .Values.webdav.ingress.tls }}
  tls:
{{ toYaml .Values.webdav.ingress.tls | indent 4 }}
  {{- end -}}
{{- end -}}
