refactor(templates)!: centralize Secret names in gitea.secret.*.name helpers
The names of the Secrets rendered by the chart were built inline in each template and, for two of them, in ad-hoc chart-wide helpers. The same name therefore existed in several places (Deployment volumes, ServiceMonitor credentials, the Secret templates themselves), which made every rename a multi-file change and allowed the references to drift apart unnoticed - the Helm unit tests render one template at a time and cannot detect a mismatching secretName. All Secret names are now defined once in templates/gitea/_secrets.tpl: gitea.secret.config.name -> <fullname>-config gitea.secret.gpg.name -> <fullname>-gpg-key (or signing.existingSecret) gitea.secret.init.name -> <fullname>-init gitea.secret.inlineConfig.name -> <fullname>-inline-config gitea.secret.metrics.name -> <fullname>-metrics gitea.gpg-key-secret-name and gitea.metrics-secret-name are removed from _helpers.tpl accordingly. A checksum/inlineConfig pod annotation is added as well. After the inline configuration had been split out of secret_config.yaml, changes to it were no longer covered by any checksum annotation and did not trigger a rollout of the Deployment. Finally the metadata attributes of the Secret templates are sorted alphabetically as required by the chart conventions. BREAKING CHANGE: two Secrets are renamed. The config Secret changes from <fullname> to <fullname>-config and the metrics Secret from <fullname>-metrics-secret to <fullname>-metrics. Helm replaces both on upgrade; references to them from outside the chart have to be adjusted. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -507,10 +507,6 @@ https
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "gitea.gpg-key-secret-name" -}}
|
|
||||||
{{ default (printf "%s-gpg-key" (include "gitea.fullname" .)) .Values.signing.existingSecret }}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- define "gitea.serviceAccountName" -}}
|
{{- define "gitea.serviceAccountName" -}}
|
||||||
{{ .Values.serviceAccount.name | default (include "gitea.fullname" .) }}
|
{{ .Values.serviceAccount.name | default (include "gitea.fullname" .) }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@@ -553,6 +549,3 @@ https
|
|||||||
{{- toYaml $probe -}}
|
{{- toYaml $probe -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "gitea.metrics-secret-name" -}}
|
|
||||||
{{ default (printf "%s-metrics-secret" (include "gitea.fullname" .)) }}
|
|
||||||
{{- end -}}
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/* names */}}
|
||||||
|
|
||||||
|
{{- define "gitea.secret.config.name" -}}
|
||||||
|
{{ include "gitea.fullname" . }}-config
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- define "gitea.secret.gpg.name" -}}
|
||||||
|
{{ default (printf "%s-gpg-key" (include "gitea.fullname" .)) .Values.signing.existingSecret }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- define "gitea.secret.init.name" -}}
|
||||||
|
{{ include "gitea.fullname" . }}-init
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- define "gitea.secret.inlineConfig.name" -}}
|
||||||
|
{{ include "gitea.fullname" . }}-inline-config
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- define "gitea.secret.metrics.name" -}}
|
||||||
|
{{ include "gitea.fullname" . }}-metrics
|
||||||
|
{{- end }}
|
||||||
@@ -28,6 +28,7 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
checksum/config: {{ include (print $.Template.BasePath "/gitea/secret_config.yaml") . | sha256sum }}
|
checksum/config: {{ include (print $.Template.BasePath "/gitea/secret_config.yaml") . | sha256sum }}
|
||||||
|
checksum/inlineConfig: {{ include (print $.Template.BasePath "/gitea/secret_inlineConfig.yaml") . | sha256sum }}
|
||||||
{{- range $idx, $value := .Values.gitea.ldap }}
|
{{- range $idx, $value := .Values.gitea.ldap }}
|
||||||
checksum/ldap_{{ $idx }}: {{ include "gitea.ldap_settings" (list $idx $value) | sha256sum }}
|
checksum/ldap_{{ $idx }}: {{ include "gitea.ldap_settings" (list $idx $value) | sha256sum }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -419,18 +420,18 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: init
|
- name: init
|
||||||
secret:
|
secret:
|
||||||
secretName: {{ include "gitea.fullname" . }}-init
|
secretName: {{ include "gitea.secret.init.name" . }}
|
||||||
defaultMode: 110
|
defaultMode: 110
|
||||||
- name: config
|
- name: config
|
||||||
secret:
|
secret:
|
||||||
secretName: {{ include "gitea.fullname" . }}
|
secretName: {{ include "gitea.secret.config.name" . }}
|
||||||
defaultMode: 110
|
defaultMode: 110
|
||||||
{{- if gt (len .Values.extraVolumes) 0 }}
|
{{- if gt (len .Values.extraVolumes) 0 }}
|
||||||
{{- toYaml .Values.extraVolumes | nindent 8 }}
|
{{- toYaml .Values.extraVolumes | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- name: inline-config-sources
|
- name: inline-config-sources
|
||||||
secret:
|
secret:
|
||||||
secretName: {{ include "gitea.fullname" . }}-inline-config
|
secretName: {{ include "gitea.secret.inlineConfig.name" . }}
|
||||||
{{- range $idx, $value := .Values.gitea.additionalConfigSources }}
|
{{- range $idx, $value := .Values.gitea.additionalConfigSources }}
|
||||||
- name: additional-config-sources-{{ $idx }}
|
- name: additional-config-sources-{{ $idx }}
|
||||||
{{- toYaml $value | nindent 10 }}
|
{{- toYaml $value | nindent 10 }}
|
||||||
@@ -440,7 +441,7 @@ spec:
|
|||||||
{{- if .Values.signing.enabled }}
|
{{- if .Values.signing.enabled }}
|
||||||
- name: gpg-private-key
|
- name: gpg-private-key
|
||||||
secret:
|
secret:
|
||||||
secretName: {{ include "gitea.gpg-key-secret-name" . }}
|
secretName: {{ include "gitea.secret.gpg.name" . }}
|
||||||
items:
|
items:
|
||||||
- key: privateKey
|
- key: privateKey
|
||||||
path: private.asc
|
path: private.asc
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "gitea.fullname" . }}
|
|
||||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
name: {{ include "gitea.secret.config.name" . }}
|
||||||
|
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
stringData:
|
stringData:
|
||||||
{{ (.Files.Glob "scripts/init-containers/config/*.sh").AsConfig | indent 2 }}
|
{{ (.Files.Glob "scripts/init-containers/config/*.sh").AsConfig | indent 2 }}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "gitea.gpg-key-secret-name" . }}
|
|
||||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
name: {{ include "gitea.secret.gpg.name" . }}
|
||||||
|
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
data:
|
data:
|
||||||
privateKey: {{ .Values.signing.privateKey | b64enc }}
|
privateKey: {{ .Values.signing.privateKey | b64enc }}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "gitea.fullname" . }}-init
|
|
||||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
name: {{ include "gitea.secret.init.name" . }}
|
||||||
|
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
stringData:
|
stringData:
|
||||||
{{ (.Files.Glob "scripts/init-containers/init/*.sh").AsConfig | indent 2 }}
|
{{ (.Files.Glob "scripts/init-containers/init/*.sh").AsConfig | indent 2 }}
|
||||||
@@ -61,7 +61,7 @@ stringData:
|
|||||||
function test_valkey_connection() {
|
function test_valkey_connection() {
|
||||||
local RETRY=0
|
local RETRY=0
|
||||||
local MAX=30
|
local MAX=30
|
||||||
|
|
||||||
echo 'Wait for valkey to become avialable...'
|
echo 'Wait for valkey to become avialable...'
|
||||||
until [ "${RETRY}" -ge "${MAX}" ]; do
|
until [ "${RETRY}" -ge "${MAX}" ]; do
|
||||||
RES_OPTIONS="ndots:0" nc -vz -w2 {{ include "valkey.servicename" . }} {{ include "valkey.port" . }} && break
|
RES_OPTIONS="ndots:0" nc -vz -w2 {{ include "valkey.servicename" . }} {{ include "valkey.port" . }} && break
|
||||||
@@ -77,7 +77,7 @@ stringData:
|
|||||||
|
|
||||||
test_valkey_connection
|
test_valkey_connection
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
|
||||||
{{- if or .Values.gitea.admin.existingSecret (and .Values.gitea.admin.username .Values.gitea.admin.password) }}
|
{{- if or .Values.gitea.admin.existingSecret (and .Values.gitea.admin.username .Values.gitea.admin.password) }}
|
||||||
function configure_admin_user() {
|
function configure_admin_user() {
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "gitea.fullname" . }}-inline-config
|
|
||||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
name: {{ include "gitea.secret.inlineConfig.name" . }}
|
||||||
|
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
stringData:
|
stringData:
|
||||||
{{- include "gitea.inline_configuration" . | nindent 2 }}
|
{{- include "gitea.inline_configuration" . | nindent 2 }}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "gitea.metrics-secret-name" . }}
|
|
||||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
|
||||||
labels:
|
labels:
|
||||||
{{- include "gitea.labels" . | nindent 4 }}
|
{{- include "gitea.labels" . | nindent 4 }}
|
||||||
|
name: {{ include "gitea.secret.metrics.name" . }}
|
||||||
|
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
data:
|
data:
|
||||||
token: {{ .Values.gitea.metrics.token | b64enc }}
|
token: {{ .Values.gitea.metrics.token | b64enc }}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ spec:
|
|||||||
authorization:
|
authorization:
|
||||||
type: Bearer
|
type: Bearer
|
||||||
credentials:
|
credentials:
|
||||||
name: {{ include "gitea.metrics-secret-name" . }}
|
name: {{ include "gitea.secret.metrics.name" . }}
|
||||||
key: token
|
key: token
|
||||||
optional: false
|
optional: false
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: fails with multiple replicas and "GIT_GC_REPOS" enabled
|
- it: fails with multiple replicas and "GIT_GC_REPOS" enabled
|
||||||
template: templates/gitea/secret_config.yaml
|
template: templates/gitea/secret_config.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: renders a deployment
|
- it: renders a deployment
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: Renders a deployment
|
- it: Renders a deployment
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: uses direct execution when extraEnvSourceFile is not set
|
- it: uses direct execution when extraEnvSourceFile is not set
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: Render the deployment (default)
|
- it: Render the deployment (default)
|
||||||
asserts:
|
asserts:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ chart:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: default values
|
- it: default values
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: renders openshift-compatible defaults for chart-managed containers
|
- it: renders openshift-compatible defaults for chart-managed containers
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: renders default liveness probe
|
- it: renders default liveness probe
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: supports adding a sidecar container
|
- it: supports adding a sidecar container
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: skips gpg init container
|
- it: skips gpg init container
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: adds gpg init container
|
- it: adds gpg init container
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ release:
|
|||||||
templates:
|
templates:
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: supports defining SSH log level for root based image
|
- it: supports defining SSH log level for root based image
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ tests:
|
|||||||
containsDocument:
|
containsDocument:
|
||||||
kind: Secret
|
kind: Secret
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
name: gitea-unittests-metrics-secret
|
name: gitea-unittests-metrics
|
||||||
- isNotNullOrEmpty:
|
- isNotNullOrEmpty:
|
||||||
path: metadata.labels
|
path: metadata.labels
|
||||||
- equal:
|
- equal:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ templates:
|
|||||||
- templates/gitea/serviceAccount.yaml
|
- templates/gitea/serviceAccount.yaml
|
||||||
- templates/gitea/deployment.yaml
|
- templates/gitea/deployment.yaml
|
||||||
- templates/gitea/secret_config.yaml
|
- templates/gitea/secret_config.yaml
|
||||||
|
- templates/gitea/secret_inlineConfig.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: does not modify the deployment by default
|
- it: does not modify the deployment by default
|
||||||
template: templates/gitea/deployment.yaml
|
template: templates/gitea/deployment.yaml
|
||||||
|
|||||||
@@ -65,6 +65,6 @@ tests:
|
|||||||
authorization:
|
authorization:
|
||||||
type: Bearer
|
type: Bearer
|
||||||
credentials:
|
credentials:
|
||||||
name: gitea-unittests-metrics-secret
|
name: gitea-unittests-metrics
|
||||||
key: token
|
key: token
|
||||||
optional: false
|
optional: false
|
||||||
|
|||||||
Reference in New Issue
Block a user