This is an automated email from the ASF dual-hosted git repository. squakez pushed a commit to branch release-2.10.x in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 021f4baa7678e6244077ae7fb0edb41a3543757c Author: Pasquale Congiusti <[email protected]> AuthorDate: Thu Aug 27 08:31:15 2026 +0200 chore(trait): verify master SA --- pkg/trait/master.go | 7 +++++++ pkg/trait/master_test.go | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/trait/master.go b/pkg/trait/master.go index 8bd60a938..262c858c6 100644 --- a/pkg/trait/master.go +++ b/pkg/trait/master.go @@ -22,6 +22,7 @@ import ( "strings" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/validation" "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime/pkg/client" @@ -209,6 +210,12 @@ func (t *masterTrait) prepareRBAC(cli client.Client, serviceAccount, itName, itN if serviceAccount == "" { serviceAccount = "default" } + if errs := validation.IsDNS1123Subdomain(serviceAccount); len(errs) > 0 { + return nil, fmt.Errorf( + "integration service account name is not properly formatted: %s", + strings.Join(errs, "; "), + ) + } templateData := struct { Namespace string diff --git a/pkg/trait/master_test.go b/pkg/trait/master_test.go index f819f295f..069639cec 100644 --- a/pkg/trait/master_test.go +++ b/pkg/trait/master_test.go @@ -337,3 +337,13 @@ func TestMasterTraitDeprecationWarning(t *testing.T) { assert.Contains(t, condition.message, "RoleBinding") assert.Contains(t, condition.message, "Quarkus properties") } + +func TestPrepareRBACFailures(t *testing.T) { + wrongSa := "my-sa\nsomethingelse" + mt := &masterTrait{ + BaseTrait: NewBaseTrait("master", TraitOrderBeforeControllerCreation), + } + _, err := mt.prepareRBAC(nil, wrongSa, "", "") + require.Error(t, err) + assert.Contains(t, err.Error(), "integration service account name is not properly formatted") +}
