feat: adding dry support to gitea additional config from envs parameter #840
@@ -256,7 +256,7 @@ https | ||||
{{- end }} | ||||
| ||||
{{- $_ := set $inlines "_generals_" (join "\n" $generals) -}} | ||||
{{- toYaml $inlines -}} | ||||
{{- tpl (toYaml $inlines) $ -}} | ||||
| | ||||
{{- end -}} | ||||
| ||||
{{- define "gitea.inline_configuration.init" -}} | ||||
| ||||
@@ -115,7 +115,7 @@ spec: | ||||
{{- toYaml .Values.deployment.env | nindent 12 }} | ||||
{{- end }} | ||||
{{- if .Values.gitea.additionalConfigFromEnvs }} | ||||
{{- toYaml .Values.gitea.additionalConfigFromEnvs | nindent 12 }} | ||||
{{- tpl (toYaml .Values.gitea.additionalConfigFromEnvs) $ | nindent 12 }} | ||||
{{- end }} | ||||
volumeMounts: | ||||
- name: config | ||||
| ||||
150 unittests/helm/deployment/deployment-additional-config.yaml Normal file
150
unittests/helm/deployment/deployment-additional-config.yaml Normal file @@ -0,0 +1,150 @@ | ||||
suite: deployment template | ||||
release: | ||||
name: gitea-unittests | ||||
namespace: testing | ||||
templates: | ||||
- templates/gitea/deployment.yaml | ||||
- templates/gitea/config.yaml | ||||
tests: | ||||
- it: Renders a deployment | ||||
template: templates/gitea/deployment.yaml | ||||
asserts: | ||||
- hasDocuments: | ||||
count: 1 | ||||
- containsDocument: | ||||
kind: Deployment | ||||
apiVersion: apps/v1 | ||||
name: gitea-unittests | ||||
- it: Deployment with empty additionalConfigFromEnvs | ||||
template: templates/gitea/deployment.yaml | ||||
set: | ||||
gitea.additionalConfigFromEnvs: [] | ||||
asserts: | ||||
- hasDocuments: | ||||
count: 1 | ||||
- exists: | ||||
path: spec.template.spec.initContainers[1].env | ||||
- lengthEqual: | ||||
path: spec.template.spec.initContainers[1].env | ||||
count: 6 | ||||
- isSubset: | ||||
path: spec.template.spec.initContainers[1] | ||||
content: | ||||
env: | ||||
- name: GITEA_APP_INI | ||||
value: /data/gitea/conf/app.ini | ||||
- name: GITEA_CUSTOM | ||||
value: /data/gitea | ||||
- name: GITEA_WORK_DIR | ||||
value: /data | ||||
- name: GITEA_TEMP | ||||
value: /tmp/gitea | ||||
- name: TMP_EXISTING_ENVS_FILE | ||||
value: /tmp/existing-envs | ||||
- name: ENV_TO_INI_MOUNT_POINT | ||||
value: /env-to-ini-mounts | ||||
- it: Deployment with standard additionalConfigFromEnvs | ||||
template: templates/gitea/deployment.yaml | ||||
set: | ||||
gitea.additionalConfigFromEnvs: [{name: GITEA_database_HOST, value: my-db:123}, {name: GITEA_database_USER, value: my-user}] | ||||
asserts: | ||||
- hasDocuments: | ||||
count: 1 | ||||
- exists: | ||||
path: spec.template.spec.initContainers[1].env | ||||
- lengthEqual: | ||||
path: spec.template.spec.initContainers[1].env | ||||
count: 8 | ||||
- isSubset: | ||||
path: spec.template.spec.initContainers[1] | ||||
content: | ||||
env: | ||||
- name: GITEA_APP_INI | ||||
value: /data/gitea/conf/app.ini | ||||
- name: GITEA_CUSTOM | ||||
value: /data/gitea | ||||
- name: GITEA_WORK_DIR | ||||
value: /data | ||||
- name: GITEA_TEMP | ||||
value: /tmp/gitea | ||||
- name: TMP_EXISTING_ENVS_FILE | ||||
value: /tmp/existing-envs | ||||
- name: ENV_TO_INI_MOUNT_POINT | ||||
value: /env-to-ini-mounts | ||||
- name: GITEA_database_HOST | ||||
value: my-db:123 | ||||
- name: GITEA_database_USER | ||||
value: my-user | ||||
- it: Deployment with templated additionalConfigFromEnvs | ||||
template: templates/gitea/deployment.yaml | ||||
set: | ||||
gitea.misc.host: my-db-host:321 | ||||
gitea.misc.user: my-db-user | ||||
gitea.additionalConfigFromEnvs: [{name: GITEA_database_HOST, value: "{{ .Values.gitea.misc.host }}"}, {name: GITEA_database_USER, value: "{{ .Values.gitea.misc.user }}"}] | ||||
asserts: | ||||
- hasDocuments: | ||||
count: 1 | ||||
- exists: | ||||
path: spec.template.spec.initContainers[1].env | ||||
- lengthEqual: | ||||
path: spec.template.spec.initContainers[1].env | ||||
count: 8 | ||||
- isSubset: | ||||
path: spec.template.spec.initContainers[1] | ||||
content: | ||||
env: | ||||
- name: GITEA_APP_INI | ||||
value: /data/gitea/conf/app.ini | ||||
- name: GITEA_CUSTOM | ||||
value: /data/gitea | ||||
- name: GITEA_WORK_DIR | ||||
value: /data | ||||
- name: GITEA_TEMP | ||||
value: /tmp/gitea | ||||
- name: TMP_EXISTING_ENVS_FILE | ||||
value: /tmp/existing-envs | ||||
- name: ENV_TO_INI_MOUNT_POINT | ||||
value: /env-to-ini-mounts | ||||
- name: GITEA_database_HOST | ||||
value: my-db-host:321 | ||||
- name: GITEA_database_USER | ||||
value: my-db-user | ||||
- it: Deployment with additionalConfigFromEnvs templated secret name | ||||
template: templates/gitea/deployment.yaml | ||||
set: | ||||
gitea.misc.existingSecret: my-db-secret | ||||
gitea.additionalConfigFromEnvs[0]: | ||||
name: GITEA_database_HOST | ||||
valueFrom: | ||||
secretKeyRef: | ||||
name: "{{ .Values.gitea.misc.existingSecret }}" | ||||
key: password | ||||
asserts: | ||||
- hasDocuments: | ||||
count: 1 | ||||
- exists: | ||||
path: spec.template.spec.initContainers[1].env | ||||
- lengthEqual: | ||||
path: spec.template.spec.initContainers[1].env | ||||
count: 7 | ||||
- isSubset: | ||||
path: spec.template.spec.initContainers[1] | ||||
content: | ||||
env: | ||||
- name: GITEA_APP_INI | ||||
value: /data/gitea/conf/app.ini | ||||
- name: GITEA_CUSTOM | ||||
value: /data/gitea | ||||
- name: GITEA_WORK_DIR | ||||
value: /data | ||||
- name: GITEA_TEMP | ||||
value: /tmp/gitea | ||||
- name: TMP_EXISTING_ENVS_FILE | ||||
value: /tmp/existing-envs | ||||
- name: ENV_TO_INI_MOUNT_POINT | ||||
value: /env-to-ini-mounts | ||||
- name: GITEA_database_HOST | ||||
valueFrom: | ||||
secretKeyRef: | ||||
name: "my-db-secret" | ||||
key: password | ||||
Reference in New Issue
Block a user
‼️ Oh dear, I completely missed this change. It breaks configuring
log.ACCESS_LOG_TEMPLATEas mentioned here: #747 (comment).Before this PR was merged a few minutes ago, I was able to configure following values so that
helm template gitea .succeeds:With these changes, the same values result in following error:
This is the kind of breaking change I wanted to prevent when posting #759 (comment). I think we should make the inline value templating "opt-in".
My bad! This one is on me; having providing some input on #759, I missed resetting my local clone on the matter
Reverting the use if
{{- tpl (toYaml $inlines) $ -}}under #846