# helm_charts_configurator-ingress.yaml
{{- if and (.Values.configurator.enabled) (.Values.configurator.ingress.enabled) }}
{{- $fullName := include "home-assistant.fullname" . -}}
{{- $servicePort := .Values.configurator.service.port -}}
{{- $ingressPath := .Values.configurator.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ $fullName }}-configurator
  labels:
    app.kubernetes.io/name: {{ include "home-assistant.name" . }}
    helm.sh/chart: {{ include "home-assistant.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.configurator.ingress.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.configurator.ingress.tls }}
  tls:
  {{- range .Values.configurator.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  {{- range .Values.configurator.ingress.hosts }}
    - host: {{ . }}
      http:
        paths:
          - path: {{ $ingressPath }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: {{ $servicePort }}
  {{- end }}
{{- end }}