tchughesiv commented on code in PR #345:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/345#discussion_r1457718421


##########
controllers/clusterplatform/clusterplatform.go:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package clusterplatform
+
+import (
+       "context"
+
+       
"github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
+       operatorapi 
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+       "github.com/apache/incubator-kie-kogito-serverless-operator/log"
+       "k8s.io/klog/v2"
+       ctrl "sigs.k8s.io/controller-runtime/pkg/client"
+)
+
+// GetActiveClusterPlatform returns the currently installed active cluster 
platform.
+func GetActiveClusterPlatform(ctx context.Context, c ctrl.Client) 
(*operatorapi.SonataFlowClusterPlatform, error) {
+       return getClusterPlatform(ctx, c, true)
+}
+
+// getClusterPlatform returns the currently installed cluster platform or any 
platform existing in the cluster.
+func getClusterPlatform(ctx context.Context, c ctrl.Client, active bool) 
(*operatorapi.SonataFlowClusterPlatform, error) {
+       klog.V(log.D).InfoS("Finding available cluster platforms")
+
+       lst, err := listPrimaryClusterPlatforms(ctx, c)
+       if err != nil {
+               return nil, err
+       }
+
+       for _, cPlatform := range lst.Items {
+               if IsActive(&cPlatform) {
+                       klog.V(log.D).InfoS("Found active cluster platform", 
"platform", cPlatform.Name)
+                       return &cPlatform, nil
+               }
+       }
+
+       if !active && len(lst.Items) > 0 {
+               // does not require the cluster platform to be active, just 
return one if present
+               res := lst.Items[0]

Review Comment:
   This is a carryover from the `SonataFlowPlatform` controller. I didn't want 
to deviate from how that controller was handling this. Maybe any changes should 
be done in both controllers with a separate PR?
   
https://github.com/apache/incubator-kie-kogito-serverless-operator/blob/add4de1acd82875206bb4de88fb2055122645d99/controllers/platform/platform.go#L143-L145



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