This is an automated email from the ASF dual-hosted git repository. squakez pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit fe9e2201dbcf7b4f70faf4f9f6bf0e26f156b128 Author: Harsh Mehta <[email protected]> AuthorDate: Wed Jun 17 11:12:07 2026 +0530 fix(builder): preserve quarkus-native task when builder.tasks is disabled Signed-off-by: Harsh Mehta <[email protected]> --- pkg/trait/builder.go | 39 +++++++++++++++++++++++++++------------ pkg/trait/builder_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index 7353eb7b1..1d90b16a6 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -245,19 +245,16 @@ func (t *builderTrait) Apply(e *Environment) error { pipelineTasks = append(pipelineTasks, v1.Task{Builder: builderTask}) // Custom tasks - if t.Tasks != nil { - if !platform.BuilderTasksEnabled() { - t.L.Info("builder.tasks is disabled by operator configuration and will be ignored") - } else { - ct, err := t.determineCustomTasks(e, builderTask, tasksConf) - if err != nil { - return err - } - if ct == nil { - return nil - } - pipelineTasks = append(pipelineTasks, ct...) + t.applyTasksFilter() + if len(t.Tasks) > 0 { + ct, err := t.determineCustomTasks(e, builderTask, tasksConf) + if err != nil { + return err } + if ct == nil { + return nil + } + pipelineTasks = append(pipelineTasks, ct...) } // Packaging task @@ -718,6 +715,24 @@ func (t *builderTrait) setPlatform(e *Environment) { // filterNodeSelector returns the node selector map after applying the operator-level allow list. // If BUILDER_NODE_SELECTOR_ALLOWED_LABELS is empty/unset all keys are accepted (backward compatible). // Otherwise only keys present in the allow list are retained; every dropped key is logged at info level. +// applyTasksFilter removes user-provided tasks when BUILDER_TASKS_ENABLED=false. +// The quarkus-native task is operator-injected and is always retained. +func (t *builderTrait) applyTasksFilter() { + if len(t.Tasks) == 0 || platform.BuilderTasksEnabled() { + return + } + kept := make([]string, 0, len(t.Tasks)) + for _, task := range t.Tasks { + name, _, _ := strings.Cut(task, ";") + if name == "quarkus-native" { + kept = append(kept, task) + } else { + t.L.Info("builder.tasks is disabled by operator configuration and will be ignored", "task", name) + } + } + t.Tasks = kept +} + func (t *builderTrait) filterNodeSelector() map[string]string { if len(t.NodeSelector) == 0 { return t.NodeSelector diff --git a/pkg/trait/builder_test.go b/pkg/trait/builder_test.go index 06555f116..c723b146f 100644 --- a/pkg/trait/builder_test.go +++ b/pkg/trait/builder_test.go @@ -771,6 +771,31 @@ func TestBuilderTraitTasksDisabledByOperator(t *testing.T) { } } +// TestBuilderTraitTasksDisabledKeepsQuarkusNative verifies that when BUILDER_TASKS_ENABLED=false +// the operator-injected quarkus-native task is preserved while user tasks are dropped. +func TestBuilderTraitTasksDisabledKeepsQuarkusNative(t *testing.T) { + t.Setenv("BUILDER_TASKS_ENABLED", "false") + + env := createBuilderTestEnv(v1.BuildStrategyPod) + bt := createNominalBuilderTraitTest() + bt.Tasks = []string{ + "quarkus-native;quarkus-image;/bin/bash -c \"build native\"", + "user-task;alpine;echo hello", + } + + err := bt.Apply(env) + require.NoError(t, err) + + var customNames []string + for _, task := range env.Pipeline { + if task.Custom != nil { + customNames = append(customNames, task.Custom.Name) + } + } + assert.Contains(t, customNames, "quarkus-native", "quarkus-native task must be preserved when builder.tasks is disabled") + assert.NotContains(t, customNames, "user-task", "user task must be dropped when builder.tasks is disabled") +} + // TestBuilderTraitTasksEnabledByDefault verifies that when BUILDER_TASKS_ENABLED is unset // custom tasks flow through normally. func TestBuilderTraitTasksEnabledByDefault(t *testing.T) {
