jordigilh commented on code in PR #372:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/372#discussion_r1478485517


##########
api/v1alpha08/sonataflow_types.go:
##########
@@ -657,8 +657,7 @@ type SonataFlowSpec struct {
        // PodTemplate describes the deployment details of this SonataFlow 
instance.
        
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="podTemplate"
        PodTemplate PodTemplateSpec `json:"podTemplate,omitempty"`
-       // Persists service to a datasource of choice. Ephemeral by default.
-       // +optional
+       // Persistence defines the database persistence configuration for the 
workflow
        Persistence *PersistenceOptions `json:"persistence,omitempty"`

Review Comment:
   Done.



##########
controllers/platform/services/services.go:
##########
@@ -276,14 +301,25 @@ func (j JobServiceHandler) GenerateServiceProperties() 
(*properties.Properties,
        props.Set(constants.KogitoServiceURLProperty, 
generateServiceURL(constants.KogitoServiceURLProtocol, j.platform.Namespace, 
j.GetServiceName()))
        props.Set(constants.JobServiceKafkaSmallRyeHealthProperty, "false")
        // add data source reactive URL
-       jspec := j.platform.Spec.Services.JobService
-       if jspec != nil && jspec.Persistence != nil && 
jspec.Persistence.PostgreSql != nil {
-               dataSourceReactiveURL, err := 
generateReactiveURL(jspec.Persistence.PostgreSql, j.GetServiceName(), 
j.platform.Namespace, constants.DefaultDatabaseName, 
constants.DefaultPostgreSQLPort)
-               if err != nil {
-                       return nil, err
+       if j.hasPostgreSQLConfigured() {
+               var dataSourceReactiveURL string
+               var err error
+               if j.platform.Spec.Services.JobService.Persistence != nil && 
j.platform.Spec.Services.JobService.Persistence.PostgreSQL != nil {
+                       dataSourceReactiveURL, err = 
generateReactiveURL(j.platform.Spec.Services.JobService.Persistence.PostgreSQL, 
j.GetServiceName(), j.platform.Namespace, constants.DefaultDatabaseName, 
constants.DefaultPostgreSQLPort)
+                       if err != nil {
+                               return nil, err
+                       }
+               } else {
+                       p := j.platform.Spec.Persistence.PostgreSQL
+                       var namespace string
+                       if len(p.ServiceRef.Namespace) > 0 {
+                               namespace = fmt.Sprintf(".%s", 
p.ServiceRef.Namespace)
+                       }
+                       dataSourceReactiveURL = 
fmt.Sprintf("%s://%s%s:%d/%s?search_path=%s", 
constants.PersistenceTypePostgreSQL, p.ServiceRef.Name, namespace, 
*p.ServiceRef.Port, p.ServiceRef.DatabaseName, j.GetServiceName())

Review Comment:
   Done.



##########
api/v1alpha08/sonataflowplatform_services_types.go:
##########
@@ -32,61 +32,8 @@ type ServiceSpec struct {
        Enabled *bool `json:"enabled,omitempty"`
        // Persists service to a datasource of choice. Ephemeral by default.
        // +optional
-       Persistence *PersistenceOptions `json:"persistence,omitempty"`
+       Persistence *PersistencePlatformSpec `json:"persistence,omitempty"`
        // PodTemplate describes the deployment details of this platform 
service instance.
        
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="podTemplate"
        PodTemplate PodTemplateSpec `json:"podTemplate,omitempty"`
 }
-
-// PersistenceOptions configure the services to persist to a datasource of 
choice
-// +kubebuilder:validation:MaxProperties=1

Review Comment:
   Added back.



##########
controllers/platform/services/properties_services_test.go:
##########
@@ -185,9 +182,6 @@ func setJobServiceEnabledValue(v *bool) plfmOptionFn {
 
 func setDataIndexEnabledValue(v *bool) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/profiles/common/properties/application_test.go:
##########
@@ -658,18 +652,15 @@ func setPlatformName(name string) plfmOptionFn {
 
 func setJobServiceJDBC(jdbc string) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/profiles/common/properties/application_test.go:
##########
@@ -634,9 +631,6 @@ func setJobServiceEnabledValue(v *bool) plfmOptionFn {
 
 func setDataIndexEnabledValue(v *bool) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/platform/platformutils.go:
##########
@@ -111,15 +111,13 @@ func setPlatformDefaults(p 
*operatorapi.SonataFlowPlatform, verbose bool) error
        }
 
        // When dataIndex object set, default to enabled if bool not set
-       if p.Spec.Services != nil {
-               var enable = true
-               if p.Spec.Services.DataIndex != nil && 
p.Spec.Services.DataIndex.Enabled == nil {
-                       p.Spec.Services.DataIndex.Enabled = &enable
-               }
-               // When the JobService field has a value, default to enabled if 
the `Enabled` field's value is nil
-               if p.Spec.Services.JobService != nil && 
p.Spec.Services.JobService.Enabled == nil {
-                       p.Spec.Services.JobService.Enabled = &enable
-               }

Review Comment:
   Done.



##########
api/v1alpha08/sonataflowplatform_types.go:
##########
@@ -45,7 +45,23 @@ type SonataFlowPlatformSpec struct {
        // Only workflows without the `sonataflow.org/profile: dev` annotation 
will be configured to use these service(s).
        // Setting this will override the use of any cluster-scoped services 
that might be defined via `SonataFlowClusterPlatform`.
        // +optional
-       Services *ServicesPlatformSpec `json:"services,omitempty"`

Review Comment:
   Done.



##########
config/manager/kustomization.yaml:
##########
@@ -16,7 +16,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
 kind: Kustomization
 images:
 - name: controller
-  newName: quay.io/kiegroup/kogito-serverless-operator-nightly

Review Comment:
   Done



##########
controllers/platform/services/properties_services_test.go:
##########
@@ -231,36 +219,30 @@ func setPlatformName(name string) plfmOptionFn {
 
 func setJobServiceJDBC(jdbc string) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/platform/services/properties_services_test.go:
##########
@@ -197,9 +191,6 @@ func setDataIndexEnabledValue(v *bool) plfmOptionFn {
 
 func emptyDataIndexServiceSpec() plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/platform/services/properties_services_test.go:
##########
@@ -173,9 +173,6 @@ func generatePlatform(opts ...plfmOptionFn) 
*operatorapi.SonataFlowPlatform {
 
 func setJobServiceEnabledValue(v *bool) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/profiles/common/properties/application_test.go:
##########
@@ -622,9 +622,6 @@ func generatePlatform(opts ...plfmOptionFn) 
*operatorapi.SonataFlowPlatform {
 
 func setJobServiceEnabledValue(v *bool) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/platform/services/properties_services_test.go:
##########
@@ -208,9 +199,6 @@ func emptyDataIndexServiceSpec() plfmOptionFn {
 
 func emptyJobServiceSpec() plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/platform/services/properties_services_test.go:
##########
@@ -231,36 +219,30 @@ func setPlatformName(name string) plfmOptionFn {
 
 func setJobServiceJDBC(jdbc string) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }
                if p.Spec.Services.JobService == nil {
                        p.Spec.Services.JobService = &operatorapi.ServiceSpec{}
                }
                if p.Spec.Services.JobService.Persistence == nil {
-                       p.Spec.Services.JobService.Persistence = 
&operatorapi.PersistenceOptions{}
+                       p.Spec.Services.JobService.Persistence = 
&operatorapi.PersistencePlatformSpec{}
                }
-               if p.Spec.Services.JobService.Persistence.PostgreSql == nil {
-                       p.Spec.Services.JobService.Persistence.PostgreSql = 
&operatorapi.PersistencePostgreSql{}
+               if p.Spec.Services.JobService.Persistence.PostgreSQL == nil {
+                       p.Spec.Services.JobService.Persistence.PostgreSQL = 
&operatorapi.PersistencePostgreSQL{}
                }
-               p.Spec.Services.JobService.Persistence.PostgreSql.JdbcUrl = jdbc
+               p.Spec.Services.JobService.Persistence.PostgreSQL.JdbcUrl = jdbc
        }
 }
 
 func setDataIndexJDBC(jdbc string) plfmOptionFn {
        return func(p *operatorapi.SonataFlowPlatform) {
-               if p.Spec.Services == nil {
-                       p.Spec.Services = &operatorapi.ServicesPlatformSpec{}
-               }

Review Comment:
   Done.



##########
controllers/platform/services/services.go:
##########
@@ -427,7 +459,7 @@ func isJobServiceSet(platform 
*operatorapi.SonataFlowPlatform) bool {
 }
 
 func isServicesSet(platform *operatorapi.SonataFlowPlatform) bool {
-       return platform != nil && platform.Spec.Services != nil

Review Comment:
   Done.



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