refactor(ingress): extract annotation, label and name rendering into helpers
The Ingress was the last chart-managed resource that built its metadata inline. Annotations were rendered with a `range` over the values map, which indents each entry manually and cannot be reused, and the resource had no way to attach additional labels. Annotations, labels and the name are now rendered by helpers in `_ingresses.tpl`, matching the pattern already used by the other resources. This also adds `ingress.labels` so extra labels can be attached to the Ingress, and reorders the `ingress` keys in `values.yaml` to the convention of `enabled`, `annotations` and `labels` first. The `$httpPort` variable was assigned before the `range` over `ingress.hosts` and therefore resolved against the wrong context once the loop rebound the dot. It has been replaced by `$.Values.service.http.port`, which reads the value from the root context at the point of use. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1144,9 +1144,10 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
|
|||||||
| Name | Description | Value |
|
| Name | Description | Value |
|
||||||
| -------------------------------- | ---------------------------------------------------------------------------------------------- | ----------------- |
|
| -------------------------------- | ---------------------------------------------------------------------------------------------- | ----------------- |
|
||||||
| `ingress.enabled` | Enable ingress | `false` |
|
| `ingress.enabled` | Enable ingress | `false` |
|
||||||
|
| `ingress.annotations` | Additional annotations. | `{}` |
|
||||||
|
| `ingress.labels` | Additional labels. | `{}` |
|
||||||
| `ingress.className` | DEPRECATED: Ingress class name. | `""` |
|
| `ingress.className` | DEPRECATED: Ingress class name. | `""` |
|
||||||
| `ingress.pathType` | Ingress Path Type | `Prefix` |
|
| `ingress.pathType` | Ingress Path Type | `Prefix` |
|
||||||
| `ingress.annotations` | Ingress annotations | `{}` |
|
|
||||||
| `ingress.hosts[0].host` | Default Ingress host | `git.example.com` |
|
| `ingress.hosts[0].host` | Default Ingress host | `git.example.com` |
|
||||||
| `ingress.hosts[0].paths[0].path` | Default Ingress path | `/` |
|
| `ingress.hosts[0].paths[0].path` | Default Ingress path | `/` |
|
||||||
| `ingress.tls` | Ingress tls settings | `[]` |
|
| `ingress.tls` | Ingress tls settings | `[]` |
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/* annotations */}}
|
||||||
|
|
||||||
|
{{- define "gitea.ingress.annotations" -}}
|
||||||
|
{{- with .Values.ingress.annotations }}
|
||||||
|
{{- toYaml . -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/* labels */}}
|
||||||
|
|
||||||
|
{{- define "gitea.ingress.labels" -}}
|
||||||
|
{{ include "gitea.labels" . }}
|
||||||
|
{{- with .Values.ingress.labels }}
|
||||||
|
{{ toYaml . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/* name */}}
|
||||||
|
|
||||||
|
{{- define "gitea.ingress.name" -}}
|
||||||
|
{{ include "gitea.fullname" . }}
|
||||||
|
{{- end }}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
{{- if .Values.ingress.enabled -}}
|
{{- if .Values.ingress.enabled -}}
|
||||||
{{- $fullName := include "gitea.fullname" . -}}
|
---
|
||||||
{{- $httpPort := .Values.service.http.port -}}
|
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ $fullName }}
|
{{- with (include "gitea.ingress.annotations" .) }}
|
||||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
|
||||||
labels:
|
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
|
||||||
annotations:
|
annotations:
|
||||||
{{- range $key, $value := .Values.ingress.annotations }}
|
{{- . | nindent 4 }}
|
||||||
{{ $key }}: {{ $value | quote }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- with (include "gitea.ingress.labels" .) }}
|
||||||
|
labels:
|
||||||
|
{{- . | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
name: {{ include "gitea.ingress.name" . }}
|
||||||
|
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: {{ tpl .Values.ingress.className . }}
|
ingressClassName: {{ tpl .Values.ingress.className . }}
|
||||||
{{- if .Values.ingress.tls }}
|
{{- if .Values.ingress.tls }}
|
||||||
@@ -38,7 +39,7 @@ spec:
|
|||||||
service:
|
service:
|
||||||
name: {{ include "gitea.service.http.name" $ }}
|
name: {{ include "gitea.service.http.name" $ }}
|
||||||
port:
|
port:
|
||||||
number: {{ $httpPort }}
|
number: {{ $.Values.service.http.port }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
- path: {{ .path | default "/" }}
|
- path: {{ .path | default "/" }}
|
||||||
pathType: {{ .pathType | default "Prefix" }}
|
pathType: {{ .pathType | default "Prefix" }}
|
||||||
@@ -46,7 +47,7 @@ spec:
|
|||||||
service:
|
service:
|
||||||
name: {{ include "gitea.service.http.name" $ }}
|
name: {{ include "gitea.service.http.name" $ }}
|
||||||
port:
|
port:
|
||||||
number: {{ $httpPort }}
|
number: {{ $.Values.service.http.port }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
@@ -56,7 +57,7 @@ spec:
|
|||||||
service:
|
service:
|
||||||
name: {{ include "gitea.service.http.name" $ }}
|
name: {{ include "gitea.service.http.name" $ }}
|
||||||
port:
|
port:
|
||||||
number: {{ $httpPort }}
|
number: {{ $.Values.service.http.port }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
+4
-2
@@ -588,17 +588,19 @@ gatewayAPI:
|
|||||||
|
|
||||||
## @section Ingress
|
## @section Ingress
|
||||||
## @param ingress.enabled Enable ingress
|
## @param ingress.enabled Enable ingress
|
||||||
|
## @param ingress.annotations Additional annotations.
|
||||||
|
## @param ingress.labels Additional labels.
|
||||||
## @param ingress.className DEPRECATED: Ingress class name.
|
## @param ingress.className DEPRECATED: Ingress class name.
|
||||||
## @param ingress.pathType Ingress Path Type
|
## @param ingress.pathType Ingress Path Type
|
||||||
## @param ingress.annotations Ingress annotations
|
|
||||||
## @param ingress.hosts[0].host Default Ingress host
|
## @param ingress.hosts[0].host Default Ingress host
|
||||||
## @param ingress.hosts[0].paths[0].path Default Ingress path
|
## @param ingress.hosts[0].paths[0].path Default Ingress path
|
||||||
## @param ingress.tls Ingress tls settings
|
## @param ingress.tls Ingress tls settings
|
||||||
ingress:
|
ingress:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
annotations: {}
|
||||||
|
labels: {}
|
||||||
className: ""
|
className: ""
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
annotations: {}
|
|
||||||
hosts:
|
hosts:
|
||||||
- host: git.example.com
|
- host: git.example.com
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
Reference in New Issue
Block a user