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 65c6249f089e289f9034eb8994bb0ca801371092 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 54aeb56b3..14cc75b76 100644 --- a/pkg/util/digest/digest.go +++ b/pkg/util/digest/digest.go @@ -112,6 +112,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 38a89ac33..0c947d568 100644 --- a/pkg/util/digest/digest_test.go +++ b/pkg/util/digest/digest_test.go @@ -149,3 +149,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) +}
