{{- if .Values.rpcInfo.ingress.enabled -}}
{{- $serviceName := printf "%s-info" (include "burrow.fullname" .) -}}
{{- $servicePort := .Values.rpcInfo.service.port -}}
{{- $pathLeader := .Values.rpcInfo.ingress.pathLeader -}}
{{- $partialIngress := .Values.rpcInfo.ingress.partial -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  labels:
    app: {{ template "burrow.name" . }}
    chart: {{ template "burrow.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "burrow.fullname" . }}-info
  annotations:
{{ toYaml .Values.rpcInfo.ingress.annotations | indent 4 }}
spec:
  rules:
{{- range $host := .Values.rpcInfo.ingress.hosts }}
    - host: {{ $host }}
      http:
        paths:
{{- if $partialIngress }}
          - path: {{ $pathLeader }}/account
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
          - path: {{ $pathLeader }}/block
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
{{- else }}
          - path: {{ $pathLeader }}
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
{{- end -}}
{{- end -}}
{{- if .Values.rpcInfo.ingress.tls }}
  tls:
{{ toYaml .Values.rpcInfo.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
