lburgazzoli commented on code in PR #5180:
URL: https://github.com/apache/camel-k/pull/5180#discussion_r1504706590


##########
pkg/util/digest/digest.go:
##########
@@ -108,10 +108,16 @@ func ComputeForIntegration(integration *v1.Integration, 
configmaps []*corev1.Con
        // Calculation logic prior to 1.10.0 (the new Traits API schema) is 
maintained
        // in order to keep consistency in the digest calculated from the same 
set of
        // Trait configurations for backward compatibility.
-       traitsMap, err := toMap(integration.Spec.Traits)
+       traits := integration.Spec.Traits.DeepCopy()
+       // Merge with executed traits
+       if err := traits.Merge(integration.Status.Traits); err != nil {

Review Comment:
   So what I'm talking about is that, if a spec trait value changes, and the 
same trait is set in the status, then the digest won't change as the status one 
overrides the spec one so the test below, fails:
   
   ```go
   func TestSpecStatusDrift(t *testing.T) {
        it := v1.Integration{}
        it.Spec.Traits.Camel = &trait.CamelTrait{}
        it.Status.Traits.Camel = &trait.CamelTrait{}
   
        it.Spec.Traits.Camel.Properties = []string{"hello=world1"}
        d1, _ := ComputeForIntegration(&it, nil, nil)
   
        it.Status.Traits.Camel.Properties = []string{"hello=world2"}
        d2, _ := ComputeForIntegration(&it, nil, nil)
   
        it.Spec.Traits.Camel.Properties = []string{"hello=world3"}
        d3, _ := ComputeForIntegration(&it, nil, nil)
   
        assert.NotEqual(t, d2, d1, "d2 must not be equal to d1")
        assert.NotEqual(t, d3, d2, "d3 must not be equal to d2")
   }
   ```
   
   ```
   === RUN   TestSpecStatusDrift
       digest_test.go:250: 
                Error Trace:    
/home/luca/work/dev/camel-k/pkg/util/digest/digest_test.go:250
                Error:          Should not be: 
"vZ9xT9oBngdDxEgHDEWFW2xqeq-rhHJK2zi-qNruAf-U"
                Test:           TestSpecStatusDrift
                Messages:       d3 must not be equal to d2
   --- FAIL: TestSpecStatusDrift (0.00s)
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to