subhramit commented on code in PR #6734:
URL: https://github.com/apache/camel-k/pull/6734#discussion_r3691969223


##########
pkg/trait/owner.go:
##########
@@ -142,3 +153,7 @@ func (t *ownerTrait) propagateLabelAndAnnotations(res 
metav1.Object, targetLabel
        }
        res.SetLabels(labels)
 }
+
+func containsWildcard(values []string) bool {
+       return slices.Contains(values, "*")

Review Comment:
   Here we are not comparing one value if its equal to `*`, but checking if any 
of the values passed (which are labels or annotations, this helper being called 
separately for both) are equal to `*`. Hence, `slices.Contains`.
   
   Although semantically, this is unlikely to happen, but since the code path 
allows it, if the user passes mixed labels or annotations, one of them being 
`*`, such as:
   ```yaml
   targetLabels:
     - app
     - team
     - "*"
     ```
   it should be treated equivalent to just `- *` (what do you think?)
   If the first value itself is equal to `*`, I trust `Contains` it will return 
early (which is same as the case of only `*` being passed that you are probably 
talking about).
   
   (This was more explicit before, but changed in 
https://github.com/apache/camel-k/pull/6734/changes/17e8f191d8af18407b7e95d1401fb5f5980c5dcc
 as per `make lint`'s suggestions).
   
   tl;dr - `slices.Contains` here is more robust to have IMO than `values[0] == 
"*"`.



-- 
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