ricardozanini commented on code in PR #316:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/316#discussion_r1424075556


##########
controllers/discovery/discovery.go:
##########
@@ -84,10 +85,10 @@ type sonataFlowServiceCatalog struct {
 }
 
 // NewServiceCatalog returns a new ServiceCatalog configured to resolve 
kubernetes, knative, and openshift resource addresses.
-func NewServiceCatalog(cli client.Client) ServiceCatalog {
+func NewServiceCatalog(cli client.Client, knDiscoveryClient 
*KnDiscoveryClient) ServiceCatalog {

Review Comment:
   Why not create the client here? Only this service requires a Knative Client 
atm.



##########
controllers/sonataflow_controller.go:
##########
@@ -95,7 +101,7 @@ func (r *SonataFlowReconciler) Reconcile(ctx 
context.Context, req ctrl.Request)
                return reconcile.Result{}, nil
        }
 
-       return profiles.NewReconciler(r.Client, workflow).Reconcile(ctx, 
workflow)
+       return factory.NewReconciler(r.Client, 
buildKnDiscoveryClient(r.Config), workflow).Reconcile(ctx, workflow)

Review Comment:
   Pass only `r.Config` here so that in the future we can create other specific 
clients if needed such as `OpenShift` or `SonataFlow`. 
   
   Also, we encapsulate the creation of KnativeClients into modules where we 
need them. wdyt?



##########
controllers/knative/knative.go:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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 knative
+
+import (
+       "k8s.io/client-go/discovery"
+       "k8s.io/client-go/rest"
+       clienteventingv1 
"knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1"
+       clientservingv1 
"knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1"
+)
+
+var servingClient clientservingv1.ServingV1Interface
+var eventingClient clienteventingv1.EventingV1Interface
+
+type Info struct {
+       IsKnativeEventing bool
+       IsKnativeServing  bool
+}

Review Comment:
   ```suggestion
   type Availability struct {
        Eventing bool
        Serving  bool
   }
   ```
   
   So we have from external packages: `knative.GetAvailability().Serving`
   
   We avoid repetition and `Info` is too generic. wdyt?



##########
controllers/discovery/knative_catalog.go:
##########
@@ -23,19 +23,73 @@ import (
        "context"
        "fmt"
 
-       "sigs.k8s.io/controller-runtime/pkg/client"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+       clienteventingv1 
"knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1"
+       clientservingv1 
"knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1"
+)
+
+const (
+       knServiceKind = "services"
+       knBrokerKind  = "brokers"
 )
 
 type knServiceCatalog struct {
-       Client client.Client
+       dc *KnDiscoveryClient
+}
+
+type KnDiscoveryClient struct {
+       ServingClient  clientservingv1.ServingV1Interface
+       EventingClient clienteventingv1.EventingV1Interface
 }
 
-func newKnServiceCatalog(cli client.Client) knServiceCatalog {
+func newKnServiceCatalog(discoveryClient *KnDiscoveryClient) knServiceCatalog {
        return knServiceCatalog{
-               Client: cli,
+               dc: discoveryClient,
+       }
+}
+
+func NewKnDiscoveryClient(servingClient clientservingv1.ServingV1Interface, 
eventingClient clienteventingv1.EventingV1Interface) *KnDiscoveryClient {

Review Comment:
   We should not export this builder.



##########
utils/knative/common.go:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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 knative

Review Comment:
   I think you can move this code to the new module `controllers/knative`



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