{{- if .Values.uiIngress.enabled -}}
{{- $releaseName := .Release.Name -}}
{{- $servicePort := .Values.HttpPort -}}
{{- $serviceName := printf "%s-%s" (include "consul.fullname" .) "ui" -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
  {{- range $key, $value := .Values.uiIngress.annotations }}
    {{ $key }}: {{ $value | quote }}
  {{- end }}
  labels:
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
    chart: {{ template "consul.chart" . }}
    component: "{{ .Release.Name }}-{{ .Values.Component }}"
  name: "{{ template "consul.fullname" . }}-ui"
spec:
  rules:
  {{- range .Values.uiIngress.hosts }}
    - host: {{ . }}
      http:
        paths:
          - backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
  {{- end -}}
  {{- if .Values.uiIngress.tls }}
  tls:
{{ toYaml .Values.uiIngress.tls | indent 4 }}
  {{- end -}}
{{- end }}
