{{- if .Values.githubWebhookServer.ingress.enabled -}}
{{- $fullName := include "actions-runner-controller-github-webhook-server.fullname" . -}}
{{- $svcPort := (index .Values.githubWebhookServer.service.ports 0).port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $fullName }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "actions-runner-controller.labels" . | nindent 4 }}
  {{- with .Values.githubWebhookServer.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if .Values.githubWebhookServer.ingress.tls }}
  tls:
    {{- range .Values.githubWebhookServer.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  {{- with .Values.githubWebhookServer.ingress.ingressClassName }}
  ingressClassName: {{ . }}
  {{- end }}
  rules:
    {{- range .Values.githubWebhookServer.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          {{- if .extraPaths }}
          {{- toYaml .extraPaths | nindent 10 }}
          {{- end }}
          {{- range .paths }}
          - path: {{ .path }}
            pathType: {{ .pathType }}
            backend:
              service:
               name: {{ $fullName }}
               port:
                 number: {{ $svcPort }}
          {{- end }}
    {{- end }}
  {{- end }}
