This is an automated email from the ASF dual-hosted git repository.

squakez pushed a commit to branch v3
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 410070fa752a9b501d9ae418efbcc60cca96dbed
Author: SunilKumarPradhan <[email protected]>
AuthorDate: Mon Oct 26 18:51:18 2026 +0530

    Fix #6874: include the Git username in the Integration digest
    
    Changing spec.git.username must trigger a new build, as it already
    happens for the URL, the secret and the branch, tag or commit. The
    username is appended to the Git part of the digest only when set, so
    the digest of existing Integrations does not change.
---
 pkg/util/digest/digest.go      |  4 ++++
 pkg/util/digest/digest_test.go | 29 +++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 202277c66..3b66a1745 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -101,6 +101,10 @@ func ComputeForIntegration(integration *v1.Integration, 
configmapVersions []stri
        // Git spec
        if integration.Spec.Git != nil {
                gitSpec := integration.Spec.Git.URL + "/" + 
integration.Spec.Git.Secret
+               // appended only when set, in order to keep the digest of the 
Integrations that do not configure it
+               if integration.Spec.Git.Username != "" {
+                       gitSpec = gitSpec + "/username:" + 
integration.Spec.Git.Username
+               }
                switch {
                case integration.Spec.Git.Tag != "":
                        gitSpec = gitSpec + "/" + integration.Spec.Git.Tag
diff --git a/pkg/util/digest/digest_test.go b/pkg/util/digest/digest_test.go
index 882ec33fc..b1f5755b5 100644
--- a/pkg/util/digest/digest_test.go
+++ b/pkg/util/digest/digest_test.go
@@ -141,3 +141,32 @@ func TestDigestMatchingTraitsUpdated(t *testing.T) {
 
        assert.NotEqual(t, itSpecOnlyTraitUpdatedDigest, itDigest, "Digests 
must not be equal")
 }
+
+func TestDigestUsesGitUsername(t *testing.T) {
+       it := v1.Integration{
+               Spec: v1.IntegrationSpec{
+                       Git: &v1.GitConfigSpec{
+                               URL:    "https://github.com/squakez/sample.git";,
+                               Secret: "my-secret",
+                       },
+               },
+       }
+       digestNoUsername, err := ComputeForIntegration(&it, nil, nil)
+       require.NoError(t, err)
+
+       // an empty username must not alter the digest, so that existing 
Integrations are not rebuilt
+       it.Spec.Git.Username = ""
+       digestEmptyUsername, err := ComputeForIntegration(&it, nil, nil)
+       require.NoError(t, err)
+       assert.Equal(t, digestNoUsername, digestEmptyUsername)
+
+       it.Spec.Git.Username = "x-token-auth"
+       digestUsername, err := ComputeForIntegration(&it, nil, nil)
+       require.NoError(t, err)
+       assert.NotEqual(t, digestNoUsername, digestUsername)
+
+       it.Spec.Git.Username = "another-user"
+       digestAnotherUsername, err := ComputeForIntegration(&it, nil, nil)
+       require.NoError(t, err)
+       assert.NotEqual(t, digestUsername, digestAnotherUsername)
+}

Reply via email to