Files
helm-gitea/unittests/helm/deployment/signing-enabled.yaml
T
volker.raschekandCopilot 229ba12744
changelog / changelog (push) Successful in 24s
check-and-test / check-and-test (push) Successful in 1m38s
feat(secrets)!: replace the gitea.admin object with secrets.admin
The admin user was the last piece of credential handling that lived outside of the `secrets` section. Worse, it was the
only credential the chart rendered as a plain environment variable value into the Deployment: unless an existing Secret
was referenced, username and password ended up in the pod spec in clear text, readable by anyone who can `get` or
`describe` the Deployment.

`gitea.admin` is therefore removed and fully replaced by `secrets.admin`:

  gitea.admin.username       -> secrets.admin.new.username
  gitea.admin.password       -> secrets.admin.new.password
  gitea.admin.email          -> secrets.admin.new.email
  gitea.admin.passwordMode   -> secrets.admin.passwordMode
  gitea.admin.existingSecret -> secrets.admin.existingSecret.{enabled,secretName}

The chart now always creates a dedicated `<fullname>-admin` Secret and the Deployment consumes `GITEA_ADMIN_USERNAME`,
`GITEA_ADMIN_PASSWORD` and `GITEA_ADMIN_EMAIL` via `secretKeyRef`. This removes the clear text credentials from the pod
spec and makes the chart-managed and the externally provided case behave identically, which previously diverged.

The email address moved into the Secret as well. It used to be interpolated directly into the init script, so changing
it rewrote the init Secret, and an operator handing over admin credentials could not supply it. The key names of an
externally provided Secret are configurable via `secrets.admin.existingSecret.{emailKey,passwordKey,usernameKey}`,
because chart-defined key names cannot be assumed for Secrets managed by an external system such as a secret store.

Admin handling was previously skipped implicitly when neither an existing Secret nor a username and password were set.
This implicit behaviour is replaced by the explicit `secrets.admin.enabled` flag, so disabling it no longer requires
blanking out unrelated values.

`gitea.admin.passwordMode` validation moved from `_helpers.tpl` to `_secrets.tpl` as
`gitea.secret.admin.passwordMode` to keep all Secret related helpers in one place. `deprecation.yaml` fails the render
when `gitea.admin` is still set and points to `secrets.admin`.

New test suites cover the rendered admin Secret, the `secretKeyRef` wiring, custom key names of an existing Secret and
the password mode validation. The `secret_admin.yaml` template is registered in every suite that renders the Deployment,
as helm-unittest requires templates referenced via `$.Template.BasePath` to be listed explicitly.

BREAKING CHANGE: The `gitea.admin` object has been removed and is replaced by `secrets.admin`. Rendering fails if
`gitea.admin` is still set. Secrets referenced via `secrets.admin.existingSecret` now additionally require an `email`
key next to `username` and `password`.

Co-authored-by: Copilot <copilot@github.com>
2026-09-03 20:43:53 +02:00

131 lines
4.3 KiB
YAML

suite: deployment template (signing enabled)
release:
name: gitea-unittests
namespace: testing
templates:
- templates/gitea/deployment.yaml
- templates/gitea/secret_admin.yaml
- templates/gitea/secret_config.yaml
- templates/gitea/secret_gpg.yaml
- templates/gitea/secret_init.yaml
- templates/gitea/secret_inlineConfig.yaml
- templates/gitea/secret_metrics.yaml
tests:
- it: adds gpg init container
template: templates/gitea/deployment.yaml
set:
secrets.gpg.enabled: true
secrets.gpg.existingSecret.enabled: true
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
asserts:
- equal:
path: spec.template.spec.initContainers[2].name
value: configure-gpg
- equal:
path: spec.template.spec.initContainers[2].command
value: ["/usr/sbinx/configure_gpg_environment.sh"]
- equal:
path: spec.template.spec.initContainers[2].securityContext
value:
runAsUser: 1000
- equal:
path: spec.template.spec.initContainers[2].env
value:
- name: GNUPGHOME
valueFrom:
secretKeyRef:
name: custom-gpg-secret
key: gpgHome
- name: TMP_RAW_GPG_KEY
value: /raw/private.asc
- equal:
path: spec.template.spec.initContainers[2].volumeMounts
value:
- name: init
mountPath: /usr/sbinx
- name: data
mountPath: /data
- name: gpg-private-key
mountPath: /raw
readOnly: true
- it: adds gpg env in `init-directories` init container
template: templates/gitea/deployment.yaml
set:
secrets.gpg.enabled: true
secrets.gpg.existingSecret.enabled: true
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
asserts:
- contains:
path: spec.template.spec.initContainers[0].env
content:
name: GNUPGHOME
valueFrom:
secretKeyRef:
name: custom-gpg-secret
key: gpgHome
- it: adds gpg env in runtime container
template: templates/gitea/deployment.yaml
set:
secrets.gpg.enabled: true
secrets.gpg.existingSecret.enabled: true
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: GNUPGHOME
valueFrom:
secretKeyRef:
name: custom-gpg-secret
key: gpgHome
- it: reads the gpg home from the configured key of an existing secret
template: templates/gitea/deployment.yaml
set:
secrets.gpg.enabled: true
secrets.gpg.existingSecret.enabled: true
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
secrets.gpg.existingSecret.gpgHomeKey: custom-gpg-home
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: GNUPGHOME
valueFrom:
secretKeyRef:
name: custom-gpg-secret
key: custom-gpg-home
- it: adds gpg volume spec
template: templates/gitea/deployment.yaml
set:
secrets.gpg.enabled: true
secrets.gpg.new.privateKey: "gpg-key-placeholder"
asserts:
- contains:
path: spec.template.spec.volumes
content:
name: gpg-private-key
secret:
secretName: gitea-unittests-gpg-key
items:
- key: privateKey
path: private.asc
defaultMode: 0100
- it: supports gpg volume spec with external reference
template: templates/gitea/deployment.yaml
set:
secrets.gpg.enabled: true
secrets.gpg.existingSecret.enabled: true
secrets.gpg.existingSecret.secretName: custom-gpg-secret
secrets.gpg.existingSecret.privateKeyKey: custom-private-key
asserts:
- contains:
path: spec.template.spec.volumes
content:
name: gpg-private-key
secret:
secretName: custom-gpg-secret
items:
- key: custom-private-key
path: private.asc
defaultMode: 0100