tadayosi commented on code in PR #3480: URL: https://github.com/apache/camel-k/pull/3480#discussion_r930567487
########## pkg/controller/integration/kits.go: ########## @@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v return kits, nil } +// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the Review Comment: typo: `ios` -> `is` ########## pkg/controller/integration/kits.go: ########## @@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v return kits, nil } +// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the +// requirements of the v1.Integration. +func sameOrMatch(kit *v1.IntegrationKit, integration *v1.Integration) (bool, error) { Review Comment: I think this func is a necessary one to have, but also wonder if `integrationMatches()` should be aware of the traits in annotations as well. Currently `integrationMatches()` only compares `it.spec.traits` with `kit.spec.traits` but shouldn't it really compare the combination of annotations and spec.traits? ########## pkg/trait/util.go: ########## @@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask { } return nil } + +// Equals return if traits set using annotations have changed. +func Equals(oldObject metav1.Object, newObject metav1.Object) bool { + if len(oldObject.GetAnnotations()) != len(newObject.GetAnnotations()) { + return false + } + + oldTraits := make(map[string]string) + newTraits := make(map[string]string) + + for k, v := range oldObject.GetAnnotations() { + if strings.HasPrefix(k, "trait.camel.apache.org/") { Review Comment: we can use `camelv1.TraitAnnotationPrefix` here. ########## pkg/trait/util.go: ########## @@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask { } return nil } + +// Equals return if traits set using annotations have changed. +func Equals(oldObject metav1.Object, newObject metav1.Object) bool { + if len(oldObject.GetAnnotations()) != len(newObject.GetAnnotations()) { + return false + } + + oldTraits := make(map[string]string) + newTraits := make(map[string]string) + + for k, v := range oldObject.GetAnnotations() { + if strings.HasPrefix(k, "trait.camel.apache.org/") { + oldTraits[k] = v + } + } + for k, v := range newObject.GetAnnotations() { + if strings.HasPrefix(k, "trait.camel.apache.org/") { Review Comment: we can use `camelv1.TraitAnnotationPrefix` here. ########## pkg/trait/util.go: ########## @@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask { } return nil } + +// Equals return if traits set using annotations have changed. +func Equals(oldObject metav1.Object, newObject metav1.Object) bool { Review Comment: I first saw the function name and misunderstood it as comparing both annotations and spec.traits. It's only when I stared at the arg types that I understood the correct intent. Apart from the function name, is it not needed to actually compare the traits under specs as well for where the func is invoked? Are changes to traits under spec handled in a different mechanics? -- 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