{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "prometheus-snmp-exporter.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "prometheus-snmp-exporter.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
  annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
  rules:
    {{- range $host := .Values.ingress.hosts }}
    - host: {{ $host }}
      http:
        paths:
          - path: /
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
    {{- end -}}
  {{- if .Values.ingress.tls }}
  tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
  {{- end -}}
{{- end -}}
