Fix #6675: disable builder.tasks injection via operator env var - #6683
Conversation
…variable control Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
squakez
left a comment
There was a problem hiding this comment.
Thanks for the work. I think we need a minor adjustment and always allows the quarkus-native which is hardcoded by the same trait. So, we need to check the existence of that task and keep it if available, whilst skipping the reset if the flag is disable.
…bled Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
Done. When |
squakez
left a comment
There was a problem hiding this comment.
Good for now. However I am realizing there is some work we need to do around the presence of the quarkus-native task. I'll create a follow up issue to work on it separately.
|
✔️ Unit test coverage report - coverage increased from 62.7% to 62.8% (+0.1%) |
|
Hi @squakez |
Summary
Adds an operator-level toggle to enable or disable custom pipeline task injection via the
builder.taskstrait, preventing CR authors from running arbitrary build containers inenvironments where that capability should be restricted.
How it works:
Set
BUILDER_TASKS_ENABLED=falseon the operator deployment to disable custom tasks:BUILDER_TASKS_ENABLED=false
"false"→ custom tasks are allowed (backward compatible, no behavior change)"false"(case-insensitive) →builder.tasksvalues are ignored; an info message is loggedWhen disabled the pod-strategy validation is also skipped, so CR authors do not receive a misleading "use pod strategy" error for tasks that will never run.
Changes
pkg/platform/env_platform.go— newBuilderTasksEnabled()readsBUILDER_TASKS_ENABLED; returnstrueby defaultpkg/trait/builder.go— gate inApply()wrapsdetermineCustomTaskscall; logs at info level and skips when disabledpkg/platform/env_platform_test.go— 5 tests covering not-set,"true","false","FALSE", and empty-string casespkg/trait/builder_test.go—TestBuilderTraitTasksDisabledByOperator(pipeline has no custom tasks when disabled) andTestBuilderTraitTasksEnabledByDefault(tasks flow through when var is unset)docs/modules/ROOT/pages/installation/builds.adoc—BUILDER_TASKS_ENABLEDadded to build env var tabledocs/modules/traits/pages/builder.adoc— "Custom Pipeline Tasks" section added with NOTE about the operator gateTest plan
make testpasses locallyTestBuilderTasksEnabled_*(platform) — env var parsing and boolean logicTestBuilderTraitTasksDisabledByOperator— verifies no custom tasks in pipeline whenBUILDER_TASKS_ENABLED=falseTestBuilderTraitTasksEnabledByDefault— verifies tasks work normally when var is unsetBUILDER_TASKS_ENABLED=false; apply an Integration withbuilder.tasksset; confirm no custom container in builder pod and info log emittedFixes #6675