Repository navigation
feat(zot): allow disabling the helm test hooks - #156
Conversation
Add test.enabled (default true) to render the helm test hooks only when enabled. With htpasswd auth and no anonymous access the hooks need authHeader, which puts the credentials into the release. Signed-off-by: Christian Bendieck <chris.bendieck@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change to make Helm test hooks optional.
No open issues 🎉
What changed in this PR
Adds an opt-out for the zot chart’s Helm test hooks, allowing deployments with other registry checks to omit the hooks without supplying test credentials. Hooks remain enabled by default.
Changes:
- Adds
test.enabled, defaulting totrue, and documents the setting. - Conditionally renders both test hooks.
- Adds unit tests covering default rendering, explicit disabling, and
test: null.
| File | Description |
|---|---|
| charts/zot/values.yaml | Defines and describes test.enabled. |
| charts/zot/unittests/test_hooks_test.yaml | Tests default, disabled, and null configurations. |
| charts/zot/templates/tests/test-connection.yaml | Gates the connection hook on test.enabled. |
| charts/zot/templates/tests/test-connection-fails.yaml | Gates the failure-check hook on test.enabled. |
| charts/zot/README.md | Documents the option and its default. |
Review effort: Balanced
andaaron
left a comment
There was a problem hiding this comment.
Please change the if so a missing test.enabled still renders the hooks. The current check skips them (charts/zot/templates/tests/test-connection.yaml:1, charts/zot/templates/tests/test-connection-fails.yaml:1).
helm upgrade --reuse-values keeps the old values. Those have test.image and no test.enabled, so both hooks disappear and helm test passes without checking the registry. A normal upgrade still gets the default true (charts/zot/values.yaml:414).
Use this on both hooks:
{{- if and .Values.test (ne .Values.test.enabled false) }}
The hook stays when the key is missing. It is skipped when enabled is false or when test is null. Please add a unit test where test.image is set and enabled is unset (charts/zot/unittests/test_hooks_test.yaml).
Signed-off-by: Christian Bendieck <chris.bendieck@gmail.com>
What type of PR is this?
feature
Which issue does this PR fix:
None.
What does this PR do / Why do we need it:
Adds
test.enabled(defaulttrue). When it isfalse, the twohelm testhooks (test-connection,test-connection-fails) are not rendered.With htpasswd auth and no
anonymousPolicy, the hooks only pass whenauthHeaderis set. The chart writesauthHeader(base64user:password) into the hook manifest, so the credentials end up in the Helm release secret (helm get hooks) and in the test pod spec. Deployments that check the registry by other means can now leave the hooks out instead of storing credentials in the release. Today there is no way to do that.The condition uses the same
and .Values.x .Values.x.enabledpattern ashttprouteandlistenerset.If an issue # is not available please add repro steps and logs showing the issue:
Without
authHeader, both hooks get401from a registry without anonymous access, sohelm testfails.Testing done on this change:
helm unittest --strict --file 'unittests/*.yaml' charts/zot: 13 suites, 104 tests passed. The new suiteunittests/test_hooks_test.yamlcovers the default (both hooks rendered),test.enabled: false(none) andtest: null(none, no render error). Against the templates onmain, two of its three cases fail.helm lint --strict charts/zot: no findings.helm templatewith default values gives the same output asmain. With--set test.enabled=falseit contains nohelm.sh/hook: testresources.ct lintandct installwere not run locally.Automation added to e2e:
No, unit tests only.
Will this break upgrades or downgrades?
No. The default is
true, so the rendered output does not change. One exception:helm upgrade --reuse-valuesdoes not pick up new chart defaults.test.enabledis then missing and the hooks are not rendered until the values are reset ortest.enabled: trueis set. The zot deployment itself is not affected.Does this PR introduce any user-facing change?:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.