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


##########
controllers/discovery/kubernetes_catalog.go:
##########
@@ -58,21 +72,97 @@ func (c k8sServiceCatalog) resolveServiceQuery(ctx 
context.Context, uri Resource
 }
 
 func (c k8sServiceCatalog) resolvePodQuery(ctx context.Context, uri 
ResourceUri, outputFormat string) (string, error) {
-       if pod, service, err := findPodAndReferenceServiceByPodLabels(ctx, 
c.Client, uri.Namespace, uri.Name); err != nil {
+       if pod, serviceList, err := findPodAndReferenceServices(ctx, c.Client, 
uri.Namespace, uri.Name); err != nil {
                return "", err
        } else {
-               if service != nil {
-                       if serviceUri, err := resolveServiceUri(service, 
uri.GetPort(), outputFormat); err != nil {
+               if serviceList != nil && len(serviceList.Items) > 0 {
+                       referenceService := 
selectBestSuitedServiceByCustomLabels(serviceList, uri.CustomLabels)
+                       return resolveServiceUri(referenceService, 
uri.GetPort(), outputFormat)
+               } else {
+                       return resolvePodUri(pod, "", uri.GetPort(), 
outputFormat)
+               }
+       }
+}
+
+func (c k8sServiceCatalog) resolveDeploymentQuery(ctx context.Context, uri 
ResourceUri, outputFormat string) (string, error) {

Review Comment:
   Yup, +1 for proposal 2. I think this diagram would make sense for runtimes, 
but not at the operator level. We can even review this diagram and add the 
constraint there since the guide should be relocated to Cloud > Operator.
   
   Anyhow, it's too complex to try to "guess" if a deployment has a pod 
available or not, too many variables that can vary (😢 ), no service, no 
discovery. Same for the StatefulSet. 👍 



##########
controllers/discovery/kubernetes_catalog.go:
##########
@@ -58,21 +72,97 @@ func (c k8sServiceCatalog) resolveServiceQuery(ctx 
context.Context, uri Resource
 }
 
 func (c k8sServiceCatalog) resolvePodQuery(ctx context.Context, uri 
ResourceUri, outputFormat string) (string, error) {
-       if pod, service, err := findPodAndReferenceServiceByPodLabels(ctx, 
c.Client, uri.Namespace, uri.Name); err != nil {
+       if pod, serviceList, err := findPodAndReferenceServices(ctx, c.Client, 
uri.Namespace, uri.Name); err != nil {
                return "", err
        } else {
-               if service != nil {
-                       if serviceUri, err := resolveServiceUri(service, 
uri.GetPort(), outputFormat); err != nil {
+               if serviceList != nil && len(serviceList.Items) > 0 {
+                       referenceService := 
selectBestSuitedServiceByCustomLabels(serviceList, uri.CustomLabels)
+                       return resolveServiceUri(referenceService, 
uri.GetPort(), outputFormat)
+               } else {
+                       return resolvePodUri(pod, "", uri.GetPort(), 
outputFormat)
+               }
+       }
+}
+
+func (c k8sServiceCatalog) resolveDeploymentQuery(ctx context.Context, uri 
ResourceUri, outputFormat string) (string, error) {

Review Comment:
   Yup, +1 for proposal 2. I think this diagram would make sense for runtimes, 
but not at the operator level. We can even review this diagram and add the 
constraint there since the guide should be relocated to Cloud > Operator.
   
   Anyhow, it's too complex to try to "guess" if a deployment has a pod 
available or not, too many variables that can vary (😢 ), no service, no 
discovery. Same for the StatefulSet. 👍 



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