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
The following commit(s) were added to refs/heads/main by this push:
new 54efa4f56 chore(trait): verify master SA
54efa4f56 is described below
commit 54efa4f56fd3b6b480536da314c4e080fc78f262
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 2ab0ee38c..4d19b64fe 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 eef995b77..c0ef60d33 100644
--- a/pkg/trait/master_test.go
+++ b/pkg/trait/master_test.go
@@ -273,3 +273,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")
+}