refactor!: remove the deprecated securityContext value
changelog / changelog (push) Successful in 34s
check-and-test / check-and-test (push) Successful in 4m30s

`securityContext` was deprecated when the chart split it into a pod-level and a container-level value. It
only ever acted as a fallback for the runtime container: when the container-level value was empty, the
deprecated map was used instead. That fallback silently changed behaviour depending on whether an unrelated
value happened to be set, and it kept a third security-related values path alive next to
`deployment.securityContext` and `deployment.gitea.securityContext`.

With the fallback gone, `gitea.runtimeContainerSecurityContext` was identical to
`gitea.containerSecurityContext`, so the helper was dropped and the Gitea container now reuses the shared
one. A deprecation check fails the render when the removed value is still set, because silently ignoring it
would drop `runAsUser`, `runAsNonRoot` or the capability set and let the container run with weaker
restrictions than intended.

BREAKING CHANGE: `securityContext` no longer exists. Use `deployment.securityContext` for the pod-level and
`deployment.gitea.securityContext` for the container-level security context. Installations that still set
`securityContext` will fail to render unless `checkDeprecation` is set to `false`.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-09-04 13:41:58 +02:00
co-authored by Copilot
parent 377306b418
commit 00ccfc6734
6 changed files with 16 additions and 17 deletions
-1
View File
@@ -1089,7 +1089,6 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----- | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| `openshift.enabled` | Enable OpenShift compatibility defaults for chart-managed pods. Defaults to auto-detect based on the SecurityContextConstraints API. | `nil` | | `openshift.enabled` | Enable OpenShift compatibility defaults for chart-managed pods. Defaults to auto-detect based on the SecurityContextConstraints API. | `nil` |
| `openshift.hostUsers` | Override the PodSpec hostUsers field for chart-managed pods. When unset, the field is omitted so the platform default is used. | `nil` | | `openshift.hostUsers` | Override the PodSpec hostUsers field for chart-managed pods. When unset, the field is omitted so the platform default is used. | `nil` |
| `securityContext` | Run init and Gitea containers as a specific securityContext | `{}` |
| `podDisruptionBudget` | Pod disruption budget | `{}` | | `podDisruptionBudget` | Pod disruption budget | `{}` |
### Route ### Route
-11
View File
@@ -146,17 +146,6 @@ These default to runAsUser 1000 outside OpenShift to preserve existing behavior.
{{- include "gitea.containerSecurityContext" (list $root $containerSecurityContext) -}} {{- include "gitea.containerSecurityContext" (list $root $containerSecurityContext) -}}
{{- end -}} {{- end -}}
{{/*
Render the runtime container securityContext while honoring the deprecated securityContext value.
*/}}
{{- define "gitea.runtimeContainerSecurityContext" -}}
{{- $containerSecurityContext := deepCopy .Values.deployment.gitea.securityContext -}}
{{- if and (eq (len $containerSecurityContext) 0) .Values.securityContext -}}
{{- $containerSecurityContext = deepCopy .Values.securityContext -}}
{{- end -}}
{{- include "gitea.containerSecurityContext" (list . $containerSecurityContext) -}}
{{- end -}}
{{/* {{/*
Storage Class Storage Class
+2 -3
View File
@@ -65,7 +65,6 @@ spec:
{{- $securityContext := include "gitea.deployment.securityContext" . | trim }} {{- $securityContext := include "gitea.deployment.securityContext" . | trim }}
{{- $containerSecurityContext := include "gitea.containerSecurityContext" (list . (deepCopy .Values.deployment.gitea.securityContext)) | trim }} {{- $containerSecurityContext := include "gitea.containerSecurityContext" (list . (deepCopy .Values.deployment.gitea.securityContext)) | trim }}
{{- $commandInitContainerSecurityContext := include "gitea.commandInitContainerSecurityContext" (list . (deepCopy .Values.deployment.gitea.securityContext)) | trim }} {{- $commandInitContainerSecurityContext := include "gitea.commandInitContainerSecurityContext" (list . (deepCopy .Values.deployment.gitea.securityContext)) | trim }}
{{- $runtimeContainerSecurityContext := include "gitea.runtimeContainerSecurityContext" . | trim }}
{{- if .Values.deployment.schedulerName }} {{- if .Values.deployment.schedulerName }}
schedulerName: "{{ .Values.deployment.schedulerName }}" schedulerName: "{{ .Values.deployment.schedulerName }}"
{{- end }} {{- end }}
@@ -405,9 +404,9 @@ spec:
{{- end }} {{- end }}
resources: resources:
{{- toYaml (.Values.deployment.gitea.resources | default dict) | nindent 12 }} {{- toYaml (.Values.deployment.gitea.resources | default dict) | nindent 12 }}
{{- if $runtimeContainerSecurityContext }} {{- if $containerSecurityContext }}
securityContext: securityContext:
{{- $runtimeContainerSecurityContext | nindent 12 }} {{- $containerSecurityContext | nindent 12 }}
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: temp - name: temp
+5
View File
@@ -90,6 +90,11 @@
{{- fail "`schedulerName` does no longer exist. Please refer to the changelog and configure `deployment.schedulerName` instead." -}} {{- fail "`schedulerName` does no longer exist. Please refer to the changelog and configure `deployment.schedulerName` instead." -}}
{{- end -}} {{- end -}}
{{/* SECURITY CONTEXT */}}
{{- if .Values.securityContext -}}
{{- fail "`securityContext` does no longer exist. Please refer to the changelog and configure `deployment.securityContext` and `deployment.gitea.securityContext` instead." -}}
{{- end -}}
{{/* STRATEGY */}} {{/* STRATEGY */}}
{{- if .Values.strategy -}} {{- if .Values.strategy -}}
{{- fail "`strategy` does no longer exist. Please refer to the changelog and configure `deployment.strategy` instead." -}} {{- fail "`strategy` does no longer exist. Please refer to the changelog and configure `deployment.strategy` instead." -}}
@@ -86,6 +86,13 @@ tests:
asserts: asserts:
- failedTemplate: - failedTemplate:
errorMessage: "`schedulerName` does no longer exist. Please refer to the changelog and configure `deployment.schedulerName` instead." errorMessage: "`schedulerName` does no longer exist. Please refer to the changelog and configure `deployment.schedulerName` instead."
- it: fails when the removed `securityContext` value is set
set:
securityContext:
runAsUser: 1000
asserts:
- failedTemplate:
errorMessage: "`securityContext` does no longer exist. Please refer to the changelog and configure `deployment.securityContext` and `deployment.gitea.securityContext` instead."
- it: fails when the removed `strategy` value is set - it: fails when the removed `strategy` value is set
set: set:
strategy: strategy:
@@ -133,6 +140,8 @@ tests:
limits: limits:
cpu: 100m cpu: 100m
schedulerName: stork schedulerName: stork
securityContext:
runAsUser: 1000
strategy: strategy:
type: Recreate type: Recreate
tolerations: tolerations:
-2
View File
@@ -306,8 +306,6 @@ openshift:
## @deprecated The securityContext variable has been split two: ## @deprecated The securityContext variable has been split two:
## - deployment.gitea.securityContext ## - deployment.gitea.securityContext
## - deployment.securityContext. ## - deployment.securityContext.
## @param securityContext Run init and Gitea containers as a specific securityContext
securityContext: {}
## @param podDisruptionBudget Pod disruption budget ## @param podDisruptionBudget Pod disruption budget
podDisruptionBudget: {} podDisruptionBudget: {}