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


##########
controllers/profiles/common/object_creators.go:
##########
@@ -197,6 +211,93 @@ func ServiceCreator(workflow *operatorapi.SonataFlow) 
(client.Object, error) {
        return service, nil
 }
 
+// SinkBindingCreator is an ObjectsCreator for SinkBinding.
+// It will create v1.SinkBinding based on events defined in workflow.
+func SinkBindingCreator(workflow *operatorapi.SonataFlow) (client.Object, 
error) {
+       lbl := workflowproj.GetDefaultLabels(workflow)
+
+       // skip if no produced event is found
+       if !properties.ContainsEventKind(workflow, cncfmodel.EventKindProduced) 
{
+               return nil, nil
+       }
+
+       sink := workflow.Spec.Sink
+       if sink == nil {
+               return nil, errors.New("Sink is not provided to create 
SinkBinding")
+       }
+
+       // subject must be deployment to inject K_SINK, service won't work
+       sinkBinding := &v1.SinkBinding{
+               ObjectMeta: metav1.ObjectMeta{
+                       Name:      strings.ToLower(fmt.Sprintf("sb-%s", 
workflow.Name)),
+                       Namespace: workflow.Namespace,
+                       Labels:    lbl,
+               },
+               Spec: v1.SinkBindingSpec{
+                       SourceSpec: duckv1.SourceSpec{
+                               Sink: *sink,
+                       },
+                       BindingSpec: duckv1.BindingSpec{
+                               Subject: tracker.Reference{
+                                       Name:       workflow.Name,
+                                       Namespace:  workflow.Namespace,
+                                       APIVersion: "apps/v1",
+                                       Kind:       "Deployment",
+                               },
+                       },
+               },
+       }
+       return sinkBinding, nil
+}
+
+// TriggersCreator is an ObjectsCreator for Triggers.
+// It will create a list of v12.Trigger based on events defined in workflow.
+func TriggersCreator(workflow *operatorapi.SonataFlow) ([]client.Object, 
error) {
+       var resultObjects []client.Object
+       lbl := workflowproj.GetDefaultLabels(workflow)
+
+       //consumed
+       events := workflow.Spec.Flow.Events
+       for _, event := range events {
+               // filter out produce events
+               if event.Kind == cncfmodel.EventKindProduced {
+                       continue
+               }
+               sink := workflow.Spec.Sink
+               if sink == nil {
+                       return nil, errors.New("Sink is not provided to create 
SinkBinding!")
+               } else if sink.Ref.Kind != "Broker" || sink.Ref.APIVersion != 
"eventing.knative.dev/v1" {
+                       return nil, errors.New("Trigger source must be a 
broker!")
+               }

Review Comment:
   yes,  I think we forgot to discuss this in the meeting. It was my bad that I 
thought trigger can use non-broker as source. Let's do this with defaults for 
this pr and create a follow up one to allow user customization.



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