{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
    name: {{ include "rtfs.fullname" . }}
    annotations:
      {{- if .Values.commonAnnotations }}
      {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 6 }}
      {{- end }}
      nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
      nginx.ingress.kubernetes.io/service-upstream: "false"
      nginx.ingress.kubernetes.io/ssl-redirect: "true"
      nginx.ingress.kubernetes.io/use-regex: "true"
      nginx.ingress.kubernetes.io/proxy-buffering: "off"
      nginx.ingress.kubernetes.io/proxy-request-buffering: "off"
      nginx.ingress.kubernetes.io/enable-underscores-in-headers: "true" 
      nginx.ingress.kubernetes.io/client-body-timeout: {{ .Values.ingress.clientBodyTimeout }}
      nginx.ingress.kubernetes.io/proxy-read-timeout: {{ .Values.ingress.grpcReadTimeout }}
      nginx.ingress.kubernetes.io/proxy-send-timeout: {{ .Values.ingress.grpcSendTimeout }}
spec:
    ingressClassName:  {{ .Values.ingress.class }}
    rules:
        - host: {{ .Values.ingress.hostname }}
          http:
              paths:
                  - path: /(.*rtfs/.*)
                    pathType: ImplementationSpecific
                    backend:
                        service:
                            name: {{ include "rtfs.fullname" . }}
                            port:
                                name: http-router
                  - path: /com.jfrog.rtfs..*
                    pathType: ImplementationSpecific
                    backend:
                        service:
                            name: {{ include "rtfs.fullname" . }}
                            port:
                                name: http-router
  {{- end }}