{{- if eq .Values.dashboard.enabled true }}
{{ if eq .Values.global.platform "kubernetes" }}
{{- if .Values.dashboard.ingress.enabled }}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
  name: {{ include "tekton-dashboard.name" . }}
  labels:
    {{- include "tekton-dashboard.labels" . | nindent 4 }}
  {{- with .Values.dashboard.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
{{- if .Values.dashboard.ingress.tls }}
  tls:
    {{- range .Values.dashboard.ingress.tls }}
    - hosts:
        {{- if .hosts }}
        {{- toYaml .hosts | nindent 8 }}
        {{- else }}
        - {{ include "tekton-dashboard.url" $ }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- if .Values.dashboard.ingress.host }}
    - host: {{ .Values.dashboard.ingress.host }}
    {{- else}}
    - host: {{ include "tekton-dashboard.url" . }}
    {{- end}}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: {{ include "tekton-dashboard.name" . }}
                port:
                  name: http
{{- end }}
{{- end }}
{{- end }}
