tchughesiv commented on code in PR #372:
URL:
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/372#discussion_r1484771915
##########
controllers/platform/services/services.go:
##########
@@ -198,11 +198,33 @@ func (d DataIndexHandler) MergePodSpec(podSpec
corev1.PodSpec) (corev1.PodSpec,
return *c, err
}
+// hasPostgreSQLConfigured returns true when either the SonataFlow Platform
PostgreSQL CR's structure or the one in the Data Index service specification is
not nil
+func (d DataIndexHandler) hasPostgreSQLConfigured() bool {
+ return d.IsServiceSetInSpec() &&
+ ((d.platform.Spec.Services.DataIndex.Persistence != nil &&
d.platform.Spec.Services.DataIndex.Persistence.PostgreSQL != nil) ||
+ (d.platform.Spec.Persistence != nil &&
d.platform.Spec.Persistence.PostgreSQL != nil))
+}
+
func (d DataIndexHandler) ConfigurePersistence(containerSpec
*corev1.Container) *corev1.Container {
- if d.platform.Spec.Services.DataIndex.Persistence != nil &&
d.platform.Spec.Services.DataIndex.Persistence.PostgreSql != nil {
+
+ if d.hasPostgreSQLConfigured() {
+ var p *operatorapi.PersistencePostgreSQL
c := containerSpec.DeepCopy()
c.Image =
d.GetServiceImageName(constants.PersistenceTypePostgreSQL)
- c.Env = append(c.Env,
persistence.ConfigurePostgreSqlEnv(d.platform.Spec.Services.DataIndex.Persistence.PostgreSql,
d.GetServiceName(), d.platform.Namespace)...)
+ if d.platform.Spec.Services.DataIndex.Persistence != nil &&
d.platform.Spec.Services.DataIndex.Persistence.PostgreSQL != nil {
+ p =
d.platform.Spec.Services.DataIndex.Persistence.PostgreSQL
+ } else {
+ p = &operatorapi.PersistencePostgreSQL{
+ SecretRef:
d.platform.Spec.Persistence.PostgreSQL.SecretRef,
+ JdbcUrl:
d.platform.Spec.Persistence.PostgreSQL.JdbcUrl,
+ }
+ if d.platform.Spec.Persistence.PostgreSQL.ServiceRef !=
nil {
+ p.ServiceRef =
&operatorapi.PostgreSQLServiceOptions{
+ SQLServiceOptions:
d.platform.Spec.Persistence.PostgreSQL.ServiceRef,
+ DatabaseSchema: d.GetServiceName()}
+ }
+ }
Review Comment:
this entire `} else {` block of code seems like something that could maybe
split our and shared between the DI and JS handlers' `ConfigurePersistence`
functions. thoughts?
--
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]