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>
131 lines
4.0 KiB
YAML
131 lines
4.0 KiB
YAML
suite: deployment template (basic)
|
|
release:
|
|
name: gitea-unittests
|
|
namespace: testing
|
|
templates:
|
|
- templates/gitea/deployment.yaml
|
|
- templates/gitea/secret_config.yaml
|
|
- templates/gitea/secret_inlineConfig.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 labels are set
|
|
template: templates/gitea/deployment.yaml
|
|
set:
|
|
deployment.labels:
|
|
hello: world
|
|
asserts:
|
|
- isSubset:
|
|
path: metadata.labels
|
|
content:
|
|
hello: world
|
|
- isSubset:
|
|
path: spec.template.metadata.labels
|
|
content:
|
|
hello: world
|
|
- isNotSubset:
|
|
path: spec.selector.matchLabels
|
|
content:
|
|
hello: world
|
|
- it: deployment labels are not in selector matchLabels
|
|
template: templates/gitea/deployment.yaml
|
|
set:
|
|
deployment.labels:
|
|
custom-label: custom-value
|
|
another-label: another-value
|
|
asserts:
|
|
- equal:
|
|
path: spec.selector.matchLabels
|
|
value:
|
|
app.kubernetes.io/name: gitea
|
|
app.kubernetes.io/instance: gitea-unittests
|
|
- it: nodeSelector is undefined
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.nodeSelector
|
|
template: templates/gitea/deployment.yaml
|
|
- it: nodeSelector is defined
|
|
set:
|
|
nodeSelector:
|
|
foo: bar
|
|
bar: foo
|
|
asserts:
|
|
- isSubset:
|
|
path: spec.template.spec.nodeSelector
|
|
content:
|
|
foo: bar
|
|
bar: foo
|
|
template: templates/gitea/deployment.yaml
|
|
|
|
- it: "injects TMP_EXISTING_ENVS_FILE as environment variable to 'init-app-ini' init container"
|
|
template: templates/gitea/deployment.yaml
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.initContainers[1].env
|
|
content:
|
|
name: TMP_EXISTING_ENVS_FILE
|
|
value: /tmp/existing-envs
|
|
- it: "injects ENV_TO_INI_MOUNT_POINT as environment variable to 'init-app-ini' init container"
|
|
template: templates/gitea/deployment.yaml
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.initContainers[1].env
|
|
content:
|
|
name: ENV_TO_INI_MOUNT_POINT
|
|
value: /env-to-ini-mounts
|
|
- it: CPU resources are defined as well as GOMAXPROCS
|
|
template: templates/gitea/deployment.yaml
|
|
set:
|
|
resources:
|
|
limits:
|
|
cpu: 200ms
|
|
memory: 200Mi
|
|
requests:
|
|
cpu: 100ms
|
|
memory: 100Mi
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: GOMAXPROCS
|
|
valueFrom:
|
|
resourceFieldRef:
|
|
divisor: "1"
|
|
resource: limits.cpu
|
|
- equal:
|
|
path: spec.template.spec.containers[0].resources
|
|
value:
|
|
limits:
|
|
cpu: 200ms
|
|
memory: 200Mi
|
|
requests:
|
|
cpu: 100ms
|
|
memory: 100Mi
|
|
- it: Init containers have correct volumeMount path
|
|
template: templates/gitea/deployment.yaml
|
|
set:
|
|
initContainersScriptsVolumeMountPath: "/custom/init/path"
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath
|
|
value: "/custom/init/path"
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath
|
|
value: "/custom/init/path"
|
|
- it: Init containers have correct volumeMount path if there is no override
|
|
template: templates/gitea/deployment.yaml
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath
|
|
value: "/usr/sbinx"
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath
|
|
value: "/usr/sbinx"
|