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:
2026-09-13 19:34:56 +02:00
co-authored by Copilot
parent 6deb39df15
commit 41dcb48564
4 changed files with 43 additions and 15 deletions
+24
View File
@@ -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 }}
+13 -12
View File
@@ -1,17 +1,18 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "gitea.fullname" . -}}
{{- $httpPort := .Values.service.http.port -}}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
labels:
{{- include "gitea.labels" . | nindent 4 }}
{{- with (include "gitea.ingress.annotations" .) }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- . | nindent 4 }}
{{- end }}
{{- with (include "gitea.ingress.labels" .) }}
labels:
{{- . | nindent 4 }}
{{- end }}
name: {{ include "gitea.ingress.name" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
spec:
ingressClassName: {{ tpl .Values.ingress.className . }}
{{- if .Values.ingress.tls }}
@@ -38,7 +39,7 @@ spec:
service:
name: {{ include "gitea.service.http.name" $ }}
port:
number: {{ $httpPort }}
number: {{ $.Values.service.http.port }}
{{- else }}
- path: {{ .path | default "/" }}
pathType: {{ .pathType | default "Prefix" }}
@@ -46,7 +47,7 @@ spec:
service:
name: {{ include "gitea.service.http.name" $ }}
port:
number: {{ $httpPort }}
number: {{ $.Values.service.http.port }}
{{- end }}
{{- end }}
{{- else }}
@@ -56,7 +57,7 @@ spec:
service:
name: {{ include "gitea.service.http.name" $ }}
port:
number: {{ $httpPort }}
number: {{ $.Values.service.http.port }}
{{- end }}
{{- end }}
{{- end }}