{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "jupyterlab.name" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "jupyterlab.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- range $k, $v := . }}
    {{ $k }}: {{ $v | quote }}
    {{- end }}
  {{- end }}
spec:
  ingressClassName: {{ .Values.ingress.ingressClassName }}
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ . }}
            pathType: Prefix
            backend:
              service:
                name: {{ include "jupyterlab.name" $ }}
                port:
                  number: 8888
          {{- end }}
    {{- end }}
{{- end }}
