wmedvede commented on code in PR #311:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/311#discussion_r1424318772


##########
controllers/platform/services/properties.go:
##########
@@ -0,0 +1,98 @@
+// Copyright 2023 Apache Software Foundation (ASF)
+//
+// Licensed 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 services
+
+import (
+       "fmt"
+       "strings"
+
+       operatorapi 
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+       
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
+       
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles/common/constants"
+
+       "github.com/magiconair/properties"
+)
+
+func generateReactiveURL(postgresSpec *operatorapi.PersistencePostgreSql, 
schema string, namespace string, dbName string, port int) string {
+       if len(postgresSpec.JdbcUrl) > 0 && 
strings.Contains(postgresSpec.JdbcUrl, "currentSchema=") {
+               return strings.Replace(strings.TrimPrefix(postgresSpec.JdbcUrl, 
"jdbc:"), "currentSchema=", "search_path=", -1)
+       }
+       databaseSchema := schema
+       if len(postgresSpec.ServiceRef.DatabaseSchema) > 0 {
+               databaseSchema = postgresSpec.ServiceRef.DatabaseSchema
+       }
+       databaseNamespace := namespace
+       if len(postgresSpec.ServiceRef.Namespace) > 0 {
+               databaseNamespace = postgresSpec.ServiceRef.Namespace
+       }
+       dataSourcePort := port
+       if postgresSpec.ServiceRef.Port != nil {
+               dataSourcePort = *postgresSpec.ServiceRef.Port
+       }
+       databaseName := dbName
+       if len(postgresSpec.ServiceRef.DatabaseName) > 0 {
+               databaseName = postgresSpec.ServiceRef.DatabaseName
+       }
+       return fmt.Sprintf("%s://%s:%d/%s?search_path=%s", 
constants.PersistenceTypePostgreSQL, 
postgresSpec.ServiceRef.Name+"."+databaseNamespace, dataSourcePort, 
databaseName, databaseSchema)
+}
+
+// GenerateDataIndexApplicationProperties returns the application properties 
required for the Data Index Service to work when deployed in a production 
profile
+// and data index' service's spec field `Enabled` set to true
+func GenerateDataIndexApplicationProperties(workflow *operatorapi.SonataFlow, 
platform *operatorapi.SonataFlowPlatform) *properties.Properties {
+       props := properties.NewProperties()
+       if profiles.IsProdProfile(workflow) && dataIndexEnabled(platform) {
+               di := NewDataIndexService(platform)
+               props.Set(
+                       constants.DataIndexServiceURLProperty,
+                       fmt.Sprintf("%s://%s.%s/processes", 
constants.DataIndexServiceURLProtocol, di.GetServiceName(), platform.Namespace),
+               )
+       }
+       return props
+}
+
+// GenerateJobServiceApplicationProperties returns the application properties 
required for the Job Service to work in a production profile and job service's
+// service's spec field `Enabled` set to true
+func GenerateJobServiceApplicationProperties(workflow *operatorapi.SonataFlow, 
platform *operatorapi.SonataFlowPlatform) *properties.Properties {
+       props := properties.NewProperties()
+       if profiles.IsProdProfile(workflow) && jobServiceEnabled(platform) {

Review Comment:
   btw,  @jordigilh  @ricardozanini the comment above regarding the 
IsProdProfile check apply also for the data-index



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