
### Description of the change Based on the discussion under https://gitea.com/gitea/helm-gitea/issues/60, it is possible to use `gitea.additionalConfigFromEnvs` to provide variables in order to override configurations from `app.ini`. Especially when using gitea as a dependency of an umbrella, some values may need to be repeated in multiple places (such has database configuration). Hence, introducing the `tpl` function on `gitea.additionalConfigFromEnvs` will simplify such repetition by having the value only set in one place... ### Benefits With the same intentions as https://gitea.com/gitea/helm-gitea/pulls/759, https://gitea.com/gitea/helm-gitea/pulls/664, https://gitea.com/gitea/helm-gitea/pulls/529 or https://gitea.com/gitea/helm-gitea/pulls/498, this change will allow reusing the value from other value parameters to avoid duplicating the same value in multiple places. ### Possible drawbacks N/A ### Applicable issues N/A ### Additional information N/A ### Checklist - [X] Helm templating unittests are added (required when changing anything in `templates` folder) Co-authored-by: 212597596 <cedric.henry@ge.com> Co-authored-by: pat-s <pat-s@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/helm-gitea/pulls/840 Reviewed-by: pat-s <pat-s@noreply.gitea.com> Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.com> Co-authored-by: Ceddaerrix <ceddaerrix@noreply.gitea.com> Co-committed-by: Ceddaerrix <ceddaerrix@noreply.gitea.com>
151 lines
5.1 KiB
YAML
151 lines
5.1 KiB
YAML
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
|