ricardozanini commented on code in PR #350:
URL:
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/350#discussion_r1455819454
##########
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:
Can you create this issue?
--
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]