{{ if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: infisical-ingress
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . | quote }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  - host: {{ .Values.ingress.hostName}}
    http: 
      paths:
      - path: {{ .Values.ingress.frontend.path }}
        pathType: {{ .Values.ingress.frontend.pathType }}
        backend:
          service:
            name: {{ include "infisical.frontend.fullname" . }}
            port:
              number: 3000
      - path: {{ .Values.ingress.backend.path }}
        pathType: {{ .Values.ingress.backend.pathType }}
        backend:
          service:
            name: {{ include "infisical.backend.fullname" . }}
            port:
              number: 4000
{{ end }}