RichardW98 commented on code in PR #350:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/350#discussion_r1454087158


##########
controllers/profiles/prod/deployment_handler.go:
##########
@@ -77,6 +79,50 @@ func (d *deploymentReconciler) reconcileWithBuiltImage(ctx 
context.Context, work
 
        objs := []client.Object{deployment, service, propsCM}
 
+       if d.Catalog.(*discovery.SonataFlowServiceCatalog).KnativeCatalog == 
nil {
+               
workflow.Status.Manager().MarkFalse(api.KnativeResourcesConditionType,
+                       api.KnativeFailureReason,
+                       "Knative Client is not installed")
+       } else if workflow.Spec.Flow.Events == nil {
+               // skip if no event is found
+               
workflow.Status.Manager().MarkTrueWithReason(api.KnativeResourcesConditionType,
+                       api.KnativeSkippedReason,
+                       "no need to create Knative eventing resources since no 
event definition is found")
+       } else if workflow.Spec.Sink == nil {
+               // mark false if spec.sink is not found
+               
workflow.Status.Manager().MarkFalse(api.KnativeResourcesConditionType,
+                       api.KnativeFailureReason,
+                       "Spec.Sink is not provided")
+       } else {
+               // create sinkBinding and trigger
+               sinkBinding, sinkBindingResult, err := 
d.ensurers.sinkBinding.Ensure(ctx, workflow, 
common.SinkBindingMutateVisitor(workflow))
+               if err != nil {
+                       return ctrl.Result{RequeueAfter: 
constants.RequeueAfterFailure}, objs, err
+               } else if sinkBinding != nil {
+                       objs = append(objs, sinkBinding)
+               }
+
+               triggers := d.ensurers.trigger.Ensure(ctx, workflow, 
common.TriggerMutateVisitor(workflow))
+               for _, trigger := range triggers {
+                       if trigger.Error != nil {
+                               return ctrl.Result{RequeueAfter: 
constants.RequeueAfterFailure}, objs, trigger.Error
+                       }
+                       objs = append(objs, trigger.Object)
+               }
+
+               if sinkBindingResult != controllerutil.OperationResultNone {
+                       // create, update should change the status
+                       
workflow.Status.Manager().MarkFalse(api.KnativeResourcesConditionType, 
api.WaitingForKnativeReason, "")
+               } else {
+                       for _, trigger := range triggers {
+                               if trigger.Result != 
controllerutil.OperationResultNone {
+                                       
workflow.Status.Manager().MarkFalse(api.KnativeResourcesConditionType, 
api.WaitingForKnativeReason, "")
+                                       break
+                               }

Review Comment:
   I will move this to common.FollowWorkflowKnativeState which manages the 
knative ensurers as well



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to