### Description of the change
Adding support for DRY principle (via use of the TPL function) to the PVC storage class and the ingress class
### Benefits
It allows to reference a variable into another one to avoid duplicating them (or using YAML anchors).
It is useful and valuable when including Gitea into an umbrella chart with multiple components and to have a single variable while the components variable only refer to that single one.
Example 1
```
global:
persistence:
storageClass: "storage-class"
persistence:
storageClass: "{{ .Values.global.persistence.storageClass }}"
```
This results in having `spec.storageClassName` equal to `storage-class` in the PVC object
Example 2
```
global:
ingress:
className: "ingress-class"
ingress:
className: "{{ .Values.global.ingress.className}}"
```
This results in having `spec.ingressClassName` equal to `ingress-class` in the Ingress object
### Possible drawbacks
N/A
### Checklist
- [X] Templating unittests are added
Co-authored-by: 212597596 <cedric.henry@ge.com>
Co-authored-by: pat-s <pat-s@noreply.gitea.com>
Co-authored-by: justusbunsi <justusbunsi@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/664
Reviewed-by: pat-s <pat-s@noreply.gitea.com>
Co-authored-by: Ceddaerrix <ceddaerrix@noreply.gitea.com>
Co-committed-by: Ceddaerrix <ceddaerrix@noreply.gitea.com>
59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
{{- if .Values.ingress.enabled -}}
|
|
{{- $fullName := include "gitea.fullname" . -}}
|
|
{{- $httpPort := .Values.service.http.port -}}
|
|
{{- $apiVersion := "extensions/v1beta1" -}}
|
|
{{- if .Values.ingress.apiVersion -}}
|
|
{{- $apiVersion = .Values.ingress.apiVersion -}}
|
|
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
|
|
{{- $apiVersion = "networking.k8s.io/v1" }}
|
|
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}}
|
|
{{- $apiVersion = "networking.k8s.io/v1beta1" }}
|
|
{{- end }}
|
|
apiVersion: {{ $apiVersion }}
|
|
kind: Ingress
|
|
metadata:
|
|
name: {{ $fullName }}
|
|
labels:
|
|
{{- include "gitea.labels" . | nindent 4 }}
|
|
annotations:
|
|
{{- range $key, $value := .Values.ingress.annotations }}
|
|
{{ $key }}: {{ $value | quote }}
|
|
{{- end }}
|
|
spec:
|
|
{{- if .Values.ingress.className }}
|
|
ingressClassName: {{ tpl .Values.ingress.className . }}
|
|
{{- end }}
|
|
{{- if .Values.ingress.tls }}
|
|
tls:
|
|
{{- range .Values.ingress.tls }}
|
|
- hosts:
|
|
{{- range .hosts }}
|
|
- {{ tpl . $ | quote }}
|
|
{{- end }}
|
|
secretName: {{ .secretName }}
|
|
{{- end }}
|
|
{{- end }}
|
|
rules:
|
|
{{- range .Values.ingress.hosts }}
|
|
- host: {{ tpl .host $ | quote }}
|
|
http:
|
|
paths:
|
|
{{- range .paths }}
|
|
- path: {{ .path }}
|
|
{{- if and .pathType (eq $apiVersion "networking.k8s.io/v1") }}
|
|
pathType: {{ .pathType }}
|
|
{{- end }}
|
|
backend:
|
|
{{- if eq $apiVersion "networking.k8s.io/v1" }}
|
|
service:
|
|
name: {{ $fullName }}-http
|
|
port:
|
|
number: {{ $httpPort }}
|
|
{{- else }}
|
|
serviceName: {{ $fullName }}-http
|
|
servicePort: {{ $httpPort }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|