feat: add dry templating to existingSecret (#112)

Successor to: https://gitea.com/gitea/helm-actions/pulls/77

---------

Co-authored-by: DaanSelen <dselen@systemec.nl>
Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/112
Reviewed-by: wxiaoguang <29147+wxiaoguang@noreply.gitea.com>
This commit is contained in:
DaanSelen
2026-04-01 14:31:31 +00:00
parent 7df376bc42
commit 78918b88f0
2 changed files with 29 additions and 2 deletions

View File

@ -84,8 +84,8 @@ spec:
- name: GITEA_RUNNER_REGISTRATION_TOKEN - name: GITEA_RUNNER_REGISTRATION_TOKEN
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: "{{ .Values.existingSecret | default $secretName }}" name: "{{ (tpl .Values.existingSecret . ) | default $secretName }}"
key: "{{ .Values.existingSecretKey | default "token" }}" key: "{{ (tpl .Values.existingSecretKey . ) | default "token" }}"
- name: GITEA_INSTANCE_URL - name: GITEA_INSTANCE_URL
value: {{ include "gitea.actions.local_root_url" . }} value: {{ include "gitea.actions.local_root_url" . }}
- name: CONFIG_FILE - name: CONFIG_FILE

View File

@ -429,6 +429,33 @@ tests:
content: content:
mountPath: /mnt mountPath: /mnt
name: my-dind-volume name: my-dind-volume
- it: should interpret existingSecret & existingSecretKey templating
template: templates/statefulset.yaml
set:
gitea:
token:
secret:
name: "gitea-secret"
key: "secret-key"
enabled: true
existingSecret: "{{ .Release.Name }}-{{ .Values.gitea.token.secret.name}}"
existingSecretKey: "{{ .Values.gitea.token.secret.key}}"
asserts:
- hasDocuments:
count: 1
- containsDocument:
kind: StatefulSet
apiVersion: apps/v1
name: gitea-unittests-actions-act-runner
- equal:
path: spec.template.spec.containers[0].env[0].name
value: "GITEA_RUNNER_REGISTRATION_TOKEN"
- equal:
path: spec.template.spec.containers[0].env[0].valueFrom.secretKeyRef.name
value: "gitea-unittests-gitea-secret"
- equal:
path: spec.template.spec.containers[0].env[0].valueFrom.secretKeyRef.key
value: "secret-key"
- it: should interpret Gitea Root URL templating - it: should interpret Gitea Root URL templating
template: templates/statefulset.yaml template: templates/statefulset.yaml
set: set: