wmedvede commented on code in PR #565:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/565#discussion_r1833117646


##########
internal/controller/profiles/preview/states_preview.go:
##########
@@ -233,3 +242,61 @@ func (h *deployWithBuildWorkflowState) 
isWorkflowChanged(workflow *operatorapi.S
        }
        return false
 }
+
+func (h *deployWithBuildWorkflowState) cleanupOutdatedRevisions(ctx 
context.Context, workflow *operatorapi.SonataFlow) error {
+       if !workflow.IsKnativeDeployment() {
+               return nil
+       }
+       avail, err := knative.GetKnativeAvailability(h.Cfg)
+       if err != nil {
+               return err
+       }
+       if !avail.Serving || !avail.Eventing {
+               return nil
+       }
+       injected, err := knative.CheckKSinkInjected(workflow.Name, 
workflow.Namespace)
+       if err != nil {
+               return err
+       }
+       if !injected {
+               return fmt.Errorf("waiting for Sinkbinding K_SINK injection to 
complete")
+       }
+       opts := &client.ListOptions{
+               LabelSelector: labels.SelectorFromSet(
+                       map[string]string{
+                               workflowproj.LabelWorkflow:          
workflow.Name,
+                               workflowproj.LabelWorkflowNamespace: 
workflow.Namespace,
+                       },
+               ),
+               Namespace: workflow.Namespace,
+       }
+       revisionList := &servingv1.RevisionList{}
+       if err := h.C.List(ctx, revisionList, opts); err != nil {

Review Comment:
   IDK if this reading is sorted, to be sure we get the revisions kind of
   revision_1
   revision_2
   revision_3
   ...
   
   I think this might have an impact on the iteration below. 



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