Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / platform / components / oauth2-proxy / components / oauth2-proxy / templates / _ingress.tpl
1 {{/*
2 Returns `true` if the API `ingressClassName` field is supported and `false` otherwise
3 */}}
4 {{- define "ingress.supportsIngressClassName" -}}
5 {{- if ( semverCompare "<1.18-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) ) -}}
6 {{- print "false" -}}
7 {{- else -}}
8 {{- print "true" -}}
9 {{- end -}}
10 {{- end -}}
11
12 {{/*
13 Returns `true` if the API `pathType` field is supported and `false` otherwise
14 */}}
15 {{- define "ingress.supportsPathType" -}}
16 {{- if ( semverCompare "<1.18-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) ) -}}
17 {{- print "false" -}}
18 {{- else -}}
19 {{- print "true" -}}
20 {{- end -}}
21 {{- end -}}
22
23 {{/*
24 Returns the appropriate ingress `backend` fields depending on the Kubernetes API version.
25 e.g.: `{{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }}`
26 Where the dict must contain the following entries:
27 - `serviceName` {String} - Name of an existing service backend
28 - `servicePort` {String|Number} - Port name or port number of the service.
29 - `context` {Dict} - (Parent) Context for the template evaluation required for the API version detection.
30 */}}
31 {{- define "ingress.backend" -}}
32 {{- $apiVersion := ( include "capabilities.ingress.apiVersion" .context ) -}}
33 {{- if or ( eq $apiVersion "extensions/v1beta1" ) ( eq $apiVersion "networking.k8s.io/v1beta1" ) -}}
34 serviceName: {{ .serviceName }}
35 servicePort: {{ .servicePort }}
36 {{- else -}}
37 service:
38   name: {{ .serviceName }}
39   port:
40     {{- if typeIs "string" .servicePort }}
41     name: {{ .servicePort }}
42     {{- else if or ( typeIs "int" .servicePort ) ( typeIs "float64" .servicePort ) }}
43     number: {{ .servicePort }}
44     {{- end }}
45 {{- end -}}
46 {{- end -}}