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


##########
controllers/platform/services/services.go:
##########
@@ -358,14 +371,26 @@ func (j JobServiceHandler) 
MergeContainerSpec(containerSpec *corev1.Container) (
        return c, err
 }
 
+// hasPostgreSQLConfigured returns true when either the SonataFlow Platform 
PostgreSQL CR's structure or the one in the Job service specification is not nil
+func (j JobServiceHandler) hasPostgreSQLConfigured() bool {
+       return (j.platform.Spec.Services.JobService.Persistence != nil && 
j.platform.Spec.Services.JobService.Persistence.PostgreSQL != nil) ||
+               (j.platform.Spec.Persistence != nil && 
j.platform.Spec.Persistence.PostgreSQL != nil)
+}
+
 func (j JobServiceHandler) ConfigurePersistence(containerSpec 
*corev1.Container) *corev1.Container {
 
-       if j.platform.Spec.Services.JobService.Persistence != nil && 
j.platform.Spec.Services.JobService.Persistence.PostgreSql != nil {
+       if j.hasPostgreSQLConfigured() {
+               var p *operatorapi.PersistencePostgreSQL
                c := containerSpec.DeepCopy()
                c.Image = 
j.GetServiceImageName(constants.PersistenceTypePostgreSQL)
-               c.Env = append(c.Env, 
persistence.ConfigurePostgreSqlEnv(j.platform.Spec.Services.JobService.Persistence.PostgreSql,
 j.GetServiceName(), j.platform.Namespace)...)
+               if j.platform.Spec.Services.JobService.Persistence != nil && 
j.platform.Spec.Services.JobService.Persistence.PostgreSQL != nil {

Review Comment:
   Not sure because adding it to `hasPostgreSQLConfigured()` already validates 
it in line 382:
   
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/372/files/95b390b7469f45c3cfad661dd5d1f845757fcdc1#diff-9168d999a0cd028523626009a2534c70de62a6e4322770f8bc21d8fc01fc2b83R382



##########
controllers/platform/services/services.go:
##########
@@ -358,14 +371,26 @@ func (j JobServiceHandler) 
MergeContainerSpec(containerSpec *corev1.Container) (
        return c, err
 }
 
+// hasPostgreSQLConfigured returns true when either the SonataFlow Platform 
PostgreSQL CR's structure or the one in the Job service specification is not nil
+func (j JobServiceHandler) hasPostgreSQLConfigured() bool {
+       return (j.platform.Spec.Services.JobService.Persistence != nil && 
j.platform.Spec.Services.JobService.Persistence.PostgreSQL != nil) ||
+               (j.platform.Spec.Persistence != nil && 
j.platform.Spec.Persistence.PostgreSQL != nil)
+}

Review Comment:
   Will add



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