tchughesiv commented on code in PR #345:
URL:
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/345#discussion_r1465097679
##########
controllers/sonataflowplatform_controller.go:
##########
@@ -166,12 +170,106 @@ func (r *SonataFlowPlatformReconciler) Reconcile(ctx
context.Context, req reconc
}
+// If an active cluster platform exists, update platform.Status accordingly
+func (r *SonataFlowPlatformReconciler) SonataFlowPlatformUpdateStatus(ctx
context.Context, req reconcile.Request, target *operatorapi.SonataFlowPlatform)
error {
+ // Fetch the active SonataFlowClusterPlatform instance
+ sfcPlatform, err := clusterplatform.GetActiveClusterPlatform(ctx,
r.Client)
+ if err != nil && !errors.IsNotFound(err) {
+ klog.V(log.E).ErrorS(err, "Failed to get active
SonataFlowClusterPlatform")
+ return err
+ }
+
+ if sfcPlatform != nil {
+ sfPlatform := &operatorapi.SonataFlowPlatform{}
+
+ platformRef := sfcPlatform.Spec.PlatformRef
+ namespacedName := types.NamespacedName{Namespace:
platformRef.Namespace, Name: platformRef.Name}
+ if req.NamespacedName == namespacedName {
+ sfPlatform = target.DeepCopy()
+ } else {
+ // retrieve referenced platform object
+ err := r.Reader.Get(ctx, namespacedName, sfPlatform)
+ if err != nil && !errors.IsNotFound(err) {
+ klog.V(log.E).ErrorS(err, "Failed to get
referenced SonataFlowPlatform", namespacedName)
+ return err
+ }
+ }
+
+ target.Status.ClusterPlatformRef =
&operatorapi.SonataFlowClusterPlatformRefStatus{
+ Name: sfcPlatform.Name,
+ PlatformRef: operatorapi.SonataFlowPlatformRef{
+ Name: platformRef.Name,
+ Namespace: platformRef.Namespace,
+ },
+ }
+
+ tpsDI := services.NewDataIndexHandler(target)
+ tpsDI.SetServiceUrlInStatus(sfPlatform)
Review Comment:
an example of the resulting status can be seen in this PR description w/ the
`example2` platform CR
--
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]