831da9caa23e21c9bb3e786b395aaf43baaff567
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / charts / postgresql / charts / common / templates / _ingress.tpl
1 {{/* vim: set filetype=mustache: */}}
2
3 {{/*
4 Generate backend entry that is compatible with all Kubernetes API versions.
5
6 Usage:
7 {{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }}
8
9 Params:
10   - serviceName - String. Name of an existing service backend
11   - servicePort - String/Int. Port name (or number) of the service. It will be translated to different yaml depending if it is a string or an integer.
12   - context - Dict - Required. The context for the template evaluation.
13 */}}
14 {{- define "common.ingress.backend" -}}
15 {{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}}
16 {{- if or (eq $apiVersion "extensions/v1beta1") (eq $apiVersion "networking.k8s.io/v1beta1") -}}
17 serviceName: {{ .serviceName }}
18 servicePort: {{ .servicePort }}
19 {{- else -}}
20 service:
21   name: {{ .serviceName }}
22   port:
23     {{- if typeIs "string" .servicePort }}
24     name: {{ .servicePort }}
25     {{- else if or (typeIs "int" .servicePort) (typeIs "float64" .servicePort) }}
26     number: {{ .servicePort | int }}
27     {{- end }}
28 {{- end -}}
29 {{- end -}}
30
31 {{/*
32 Print "true" if the API pathType field is supported
33 Usage:
34 {{ include "common.ingress.supportsPathType" . }}
35 */}}
36 {{- define "common.ingress.supportsPathType" -}}
37 {{- if (semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .)) -}}
38 {{- print "false" -}}
39 {{- else -}}
40 {{- print "true" -}}
41 {{- end -}}
42 {{- end -}}
43
44 {{/*
45 Returns true if the ingressClassname field is supported
46 Usage:
47 {{ include "common.ingress.supportsIngressClassname" . }}
48 */}}
49 {{- define "common.ingress.supportsIngressClassname" -}}
50 {{- if semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .) -}}
51 {{- print "false" -}}
52 {{- else -}}
53 {{- print "true" -}}
54 {{- end -}}
55 {{- end -}}
56
57 {{/*
58 Return true if cert-manager required annotations for TLS signed
59 certificates are set in the Ingress annotations
60 Ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations
61 Usage:
62 {{ include "common.ingress.certManagerRequest" ( dict "annotations" .Values.path.to.the.ingress.annotations ) }}
63 */}}
64 {{- define "common.ingress.certManagerRequest" -}}
65 {{ if or (hasKey .annotations "cert-manager.io/cluster-issuer") (hasKey .annotations "cert-manager.io/issuer") (hasKey .annotations "kubernetes.io/tls-acme") }}
66     {{- true -}}
67 {{- end -}}
68 {{- end -}}