Skip to content

Commit

Permalink
Refactored ConfigurePersistence() in JobServiceHandler to use functio…
Browse files Browse the repository at this point in the history
…n RetrievePersistence()
  • Loading branch information
jordigilh committed Feb 27, 2024
1 parent 0a22b9c commit 214e0b2
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions controllers/platform/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,23 +376,10 @@ func (j JobServiceHandler) hasPostgreSQLConfigured() bool {
func (j JobServiceHandler) ConfigurePersistence(containerSpec *corev1.Container) *corev1.Container {

if j.hasPostgreSQLConfigured() {
var p *operatorapi.PersistencePostgreSQL
c := containerSpec.DeepCopy()
c.Image = j.GetServiceImageName(constants.PersistenceTypePostgreSQL)
if j.platform.Spec.Services.JobService.Persistence != nil && j.platform.Spec.Services.JobService.Persistence.PostgreSQL != nil {
p = j.platform.Spec.Services.JobService.Persistence.PostgreSQL
} else {
p = &operatorapi.PersistencePostgreSQL{
SecretRef: j.platform.Spec.Persistence.PostgreSQL.SecretRef,
JdbcUrl: j.platform.Spec.Persistence.PostgreSQL.JdbcUrl,
}
if j.platform.Spec.Persistence.PostgreSQL.ServiceRef != nil {
p.ServiceRef = &operatorapi.PostgreSQLServiceOptions{
SQLServiceOptions: j.platform.Spec.Persistence.PostgreSQL.ServiceRef,
DatabaseSchema: j.GetServiceName()}
}
}
c.Env = append(c.Env, persistence.ConfigurePostgreSQLEnv(p, j.GetServiceName(), j.platform.Namespace)...)
p := persistence.RetrieveConfiguration(j.platform.Spec.Services.JobService.Persistence, j.platform.Spec.Persistence, j.GetServiceName())
c.Env = append(c.Env, persistence.ConfigurePostgreSQLEnv(p.PostgreSQL, j.GetServiceName(), j.platform.Namespace)...)
// Specific to Job Service
c.Env = append(c.Env, corev1.EnvVar{Name: "QUARKUS_FLYWAY_MIGRATE_AT_START", Value: "true"})
return c
Expand Down

0 comments on commit 214e0b2

Please sign in to comment.