squakez commented on code in PR #4987:
URL: https://github.com/apache/camel-k/pull/4987#discussion_r1427864383


##########
pkg/controller/integration/kits.go:
##########
@@ -257,10 +259,32 @@ func matchesTrait(it map[string]interface{}, kt 
map[string]interface{}) bool {
 }
 
 func hasMatchingSources(it *v1.Integration, kit *v1.IntegrationKit) bool {

Review Comment:
   We should rename this to clearly state is used in native situations only, 
ie, `hasMatchingSourceForNative` and ideally add a short comment declaring the 
intent of this method.



##########
pkg/controller/integration/kits.go:
##########
@@ -257,10 +259,32 @@ func matchesTrait(it map[string]interface{}, kt 
map[string]interface{}) bool {
 }
 
 func hasMatchingSources(it *v1.Integration, kit *v1.IntegrationKit) bool {
-       if len(it.Sources()) != len(kit.Spec.Sources) {
+       // A kit may have fewer sources during native builds but should not 
have more
+       if len(kit.Spec.Sources) > len(it.Sources()) {
                return false
        }
+
+       isNativeKit := false
+       if kit.Spec.Traits.Quarkus != nil {
+               // TODO: Verify proper way to determine mode
+               mode := kit.Spec.Traits.Quarkus.Modes[0]
+               isNativeKit = mode == traitv1.NativeQuarkusMode
+       }
+
+       var kitRuntimeCatalog *camel.RuntimeCatalog
+       if isNativeKit {
+               var err error
+               kitRuntimeCatalog, err = 
camel.GetVersionedCatalog(kit.Status.RuntimeVersion)
+               if err != nil {
+                       // TODO: log error here?
+                       return false
+               }
+       }
+
        for _, itSource := range it.Sources() {
+               if isNativeKit && !sourceRequiredByKitCatalog(itSource, 
kitRuntimeCatalog) {

Review Comment:
   The only thing we need to do is to filter off the `it.Sources()` func those 
sources that were generated by the operator (Openapi spec but likely also 
kamelets). Maybe we can introduce another func called `it.UserSources()` 
listing only the non generated sources which we'll be using in this func to 
check.
   
   We probably need to apply the same change into quarkus trait code func 
`propagateSourcesRequiredAtBuildTime()` in order to use the same 
`it.UserSources()` and have a consistent propagation of the same sources we'll 
be later comparing.



##########
pkg/controller/integration/kits.go:
##########
@@ -257,10 +259,32 @@ func matchesTrait(it map[string]interface{}, kt 
map[string]interface{}) bool {
 }
 
 func hasMatchingSources(it *v1.Integration, kit *v1.IntegrationKit) bool {
-       if len(it.Sources()) != len(kit.Spec.Sources) {
+       // A kit may have fewer sources during native builds but should not 
have more
+       if len(kit.Spec.Sources) > len(it.Sources()) {

Review Comment:
   We may remove this check completely. It would make sense in case of a clear 
not equality only IMO.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to