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


##########
controllers/clusterplatform/initialize.go:
##########
@@ -0,0 +1,118 @@
+/*
+ * 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"
+       "fmt"
+
+       "github.com/apache/incubator-kie-kogito-serverless-operator/api"
+       
"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"
+       k8serrors "k8s.io/apimachinery/pkg/api/errors"
+       "k8s.io/apimachinery/pkg/types"
+       "k8s.io/klog/v2"
+)
+
+// NewInitializeAction returns an action that initializes the platform 
configuration when not provided by the user.
+func NewInitializeAction() Action {
+       return &initializeAction{}
+}
+
+type initializeAction struct {
+       baseAction
+}
+
+func (action *initializeAction) Name() string {
+       return "initialize"
+}
+
+func (action *initializeAction) CanHandle(ctx context.Context, cPlatform 
*operatorapi.SonataFlowClusterPlatform) bool {
+       return !cPlatform.Status.IsDuplicated() || 
allDuplicatedClusterPlatforms(ctx, action.client)
+}
+
+func (action *initializeAction) Handle(ctx context.Context, cPlatform 
*operatorapi.SonataFlowClusterPlatform) error {
+       duplicate, err := action.isPrimaryDuplicate(ctx, cPlatform)
+       if err != nil {
+               return err
+       }
+       if duplicate {
+               // another cluster platform already present
+               if !cPlatform.Status.IsDuplicated() {
+                       
cPlatform.Status.Manager().MarkFalse(api.SucceedConditionType, 
operatorapi.PlatformDuplicatedReason, "")
+               }
+               return nil
+       }
+       cPlatform.Status.Version = metadata.SpecVersion
+       platformRef := cPlatform.Spec.PlatformRef
+
+       // Check referenced platform status
+       platform := &operatorapi.SonataFlowPlatform{}
+       err = action.client.Get(ctx, types.NamespacedName{Namespace: 
platformRef.Namespace, Name: platformRef.Name}, platform)
+       if err != nil {
+               if k8serrors.IsNotFound(err) {
+                       klog.V(log.D).InfoS("%s platform does not exist in %s 
namespace.", platformRef.Name, platformRef.Namespace)
+                       
cPlatform.Status.Manager().MarkFalse(api.SucceedConditionType, 
operatorapi.PlatformNotFoundReason,
+                               fmt.Sprintf("%s platform does not exist in %s 
namespace.", platformRef.Name, platformRef.Namespace))
+                       return nil
+               }
+               return err
+       }
+
+       if platform != nil {

Review Comment:
   this is out of scope, and was listed as out of scope in the ADR. it's worth 
noting though, that in a cluster w/ default network settings there should be 
nothing restricting namespace and namespace communication.
   
   should a cluster administrator decide to implement network policies of some 
sort, they will have to account for that, which will be no different than any 
other installed application in that cluster.



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