{{- if .Values.static.ingress.enabled -}}
{{- $fullName := include "gitdata.fullname" . -}}
{{- $ns := include "gitdata.namespace" . -}}
{{- $ing := .Values.static.ingress -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $fullName }}-static
  namespace: {{ $ns }}
  labels:
    app.kubernetes.io/name: {{ $fullName }}-static
    app.kubernetes.io/instance: {{ .Release.Name }}
  annotations:
    cert-manager.io/cluster-issuer: {{ $ing.clusterIssuer | default "cloudflare-acme-cluster-issuer" }}
{{- if $ing.annotations }}
{{ toYaml $ing.annotations | indent 4 }}
{{- end }}
{{- if not (hasKey ($ing.annotations | default dict) "nginx.ingress.kubernetes.io/proxy-body-size") }}
{{- if or (not $ing.className) (eq $ing.className "nginx") (contains "nginx" $ing.className) }}
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
{{- end }}
{{- end }}
spec:
{{- if $ing.className }}
  ingressClassName: {{ $ing.className }}
{{- end }}
{{- if $ing.tls }}
  tls:
{{- range $ing.tls }}
  - hosts:
{{- range .hosts }}
    - {{ . | quote }}
{{- end }}
    secretName: {{ .secretName }}
{{- end }}
{{- else }}
  tls:
{{- range $ing.hosts }}
  - hosts:
    - {{ .host | quote }}
    secretName: {{ $fullName }}-static-tls
{{- end }}
{{- end }}
  rules:
{{- range $ing.hosts }}
  - host: {{ .host | quote }}
    http:
      paths:
{{- range .paths }}
      - path: {{ .path }}
        pathType: {{ .pathType | default "Prefix" }}
        backend:
          service:
            name: {{ $fullName }}-static
            port:
              number: {{ $.Values.static.service.port }}
{{- end }}
{{- end }}
{{- end }}
