{{- if .Values.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "nexus.fullname" . }}
  labels:
{{ include "nexus.labels" . | indent 4 }}
  annotations:
    {{- range $key, $value := .Values.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  rules:
    - host: {{ .Values.nexusProxy.env.nexusHttpHost }}
      http:
        paths:
          - backend:
              serviceName: {{ template "nexus.fullname" . }}
              servicePort: {{ .Values.nexusProxy.port }}
            path: {{ .Values.ingress.path }}
    - host: {{ .Values.nexusProxy.env.nexusDockerHost }}
      http:
        paths:
          - backend:
              serviceName: {{ template "nexus.fullname" . }}
              servicePort: {{ .Values.nexusProxy.port }}
            path: {{ .Values.ingress.path }}
{{- if .Values.ingress.tls.enabled }}
  tls:
    - hosts:
        - {{ .Values.nexusProxy.env.nexusHttpHost }}
        - {{ .Values.nexusProxy.env.nexusDockerHost }}
      {{- if .Values.ingress.tls.secretName }}
      secretName: {{ .Values.ingress.tls.secretName | quote }}
      {{- end }}
{{- end -}}
{{- end }}
