You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/06/15 08:31:20 UTC

[GitHub] [camel-k] squakez commented on a diff in pull request #3358: Improve multi operator handling and multi tenancy model

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


##########
pkg/apis/camel/v1/integration_types_support.go:
##########
@@ -255,6 +255,15 @@ func (in *SourceSpec) InferLanguage() Language {
 	return ""
 }
 
+// SetOperatorID sets the given operator id as an annotation
+func (in *Integration) SetOperatorID(operatorID string) {
+	if in.Annotations == nil {
+		in.Annotations = make(map[string]string)
+	}
+
+	in.Annotations[OperatorIDAnnotation] = operatorID
+}
+

Review Comment:
   Duplicated code. We may have a single method with that logic, and call it from the various entities



##########
pkg/cmd/bind.go:
##########
@@ -217,6 +235,36 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args []string) error {
 		binding.Spec.Integration.Traits = traits
 	}
 
+	if binding.Annotations == nil {
+		binding.Annotations = make(map[string]string)
+	}
+
+	if o.OperatorID != "" {
+		if pl, err := platformutil.LookupForPlatformName(o.Context, client, o.OperatorID); err != nil {
+			if k8serrors.IsForbidden(err) {
+				o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorID)
+			} else {
+				return err
+			}
+		} else if pl == nil {
+			if o.Force {
+				o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - Kamelet binding may not be reconciled and get stuck in waiting state\n", o.OperatorID)
+			} else {
+				return fmt.Errorf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorID)
+			}
+		}
+	}

Review Comment:
   Duplicated code: we better make it an util function to be used from all the other parts



##########
pkg/cmd/run.go:
##########
@@ -108,6 +108,7 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
 	cmd.Flags().Bool("sync", false, "Synchronize the local source file with the cluster, republishing at each change")
 	cmd.Flags().Bool("dev", false, "Enable Dev mode (equivalent to \"-w --logs --sync\")")
 	cmd.Flags().Bool("use-flows", true, "Write yaml sources as Flow objects in the integration custom resource")
+	cmd.Flags().String("operator-id", "camel-k", "Operator id selected to manage this integration.")

Review Comment:
   I'd add a "x" short param as well, so we can use "-x" instead the longer "--operator-id".



-- 
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-unsubscribe@camel.apache.org

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