@@ -121,44 +121,41 @@ func (r *RepoManagerReconciler) createSecrets(ctx context.Context, pulp *pulpv1.
121121func pulpServerSecret (resources controllers.FunctionResources ) client.Object {
122122
123123 pulp := resources .Pulp
124- pulp_settings := ""
124+ pulp_settings := controllers . DotNotEditMessage
125125
126- // default settings.py configuration
127- defaultPulpSettings (resources , & pulp_settings )
126+ // add custom settings to the secret
127+ customSettings := addCustomPulpSettings (resources , & pulp_settings )
128128
129129 // pulpcore debug log
130130 debugLogging (resources , & pulp_settings )
131131
132132 // db settings
133- databaseSettings (resources , & pulp_settings )
133+ databaseSettings (resources , & pulp_settings , customSettings )
134134
135135 // add cache settings
136136 cacheSettings (resources , & pulp_settings )
137137
138138 // azure settings
139- azureSettings (resources , & pulp_settings )
139+ azureSettings (resources , & pulp_settings , customSettings )
140140
141141 // s3 settings
142- s3Settings (resources , & pulp_settings )
142+ s3Settings (resources , & pulp_settings , customSettings )
143143
144144 // configure settings.py with keycloak integration variables
145145 ssoConfig (resources , & pulp_settings )
146146
147147 // configure TOKEN_SERVER based on ingress_type
148- tokenSettings (resources , & pulp_settings )
148+ tokenSettings (resources , & pulp_settings , customSettings )
149149
150150 // django SECRET_KEY
151- secretKeySettings (resources , & pulp_settings )
151+ secretKeySettings (resources , & pulp_settings , customSettings )
152152
153153 // allowed content checksum
154- allowedContentChecksumsSettings (resources , & pulp_settings )
154+ allowedContentChecksumsSettings (resources , & pulp_settings , customSettings )
155155
156156 // ldap auth config
157157 ldapSettings (resources , & pulp_settings )
158158
159- // add custom settings to the secret
160- addCustomPulpSettings (resources , & pulp_settings )
161-
162159 sec := & corev1.Secret {
163160 ObjectMeta : metav1.ObjectMeta {
164161 Name : settings .PulpServerSecret (pulp .Name ),
@@ -244,22 +241,6 @@ func pulpContainerAuth(resources controllers.FunctionResources) client.Object {
244241 }
245242}
246243
247- // defaultPulpSettings appends some common settings into pulpSettings
248- func defaultPulpSettings (resources controllers.FunctionResources , pulpSettings * string ) {
249- rootUrl := getRootURL (resources )
250- * pulpSettings = * pulpSettings + controllers .DotNotEditMessage + `
251- DB_ENCRYPTION_KEY = "/etc/pulp/keys/database_fields.symmetric.key"
252- ANSIBLE_API_HOSTNAME = "` + rootUrl + `"
253- ANSIBLE_CERTS_DIR = "/etc/pulp/keys/"
254- CONTENT_ORIGIN = "` + rootUrl + `"
255- PRIVATE_KEY_PATH = "/etc/pulp/keys/container_auth_private_key.pem"
256- PUBLIC_KEY_PATH = "/etc/pulp/keys/container_auth_public_key.pem"
257- STATIC_ROOT = "/var/lib/operator/static/"
258- TOKEN_AUTH_DISABLED = False
259- TOKEN_SIGNATURE_ALGORITHM = "ES256"
260- `
261- }
262-
263244// cacheSettings appends redis/cache settings into pulpSettings
264245func cacheSettings (resources controllers.FunctionResources , pulpSettings * string ) {
265246 pulp := resources .Pulp
@@ -296,7 +277,11 @@ REDIS_DB = "` + cacheDB + `"
296277}
297278
298279// databaseSettings appends postgres settings into pulpSettings
299- func databaseSettings (resources controllers.FunctionResources , pulpSettings * string ) {
280+ func databaseSettings (resources controllers.FunctionResources , pulpSettings * string , customSettings map [string ]struct {}) {
281+ if _ , exists := customSettings ["DATABASES" ]; exists {
282+ return
283+ }
284+
300285 pulp := resources .Pulp
301286 logger := resources .Logger
302287 context := resources .Context
@@ -352,7 +337,11 @@ func databaseSettings(resources controllers.FunctionResources, pulpSettings *str
352337}
353338
354339// azureSettings appends azure blob object storage settings into pulpSettings
355- func azureSettings (resources controllers.FunctionResources , pulpSettings * string ) {
340+ func azureSettings (resources controllers.FunctionResources , pulpSettings * string , customSettings map [string ]struct {}) {
341+ if _ , exists := customSettings ["STORAGES" ]; exists {
342+ return
343+ }
344+
356345 pulp := resources .Pulp
357346 logger := resources .Logger
358347 context := resources .Context
@@ -392,7 +381,10 @@ STORAGES = {
392381}
393382
394383// s3Settings appends s3 object storage settings into pulpSettings
395- func s3Settings (resources controllers.FunctionResources , pulpSettings * string ) {
384+ func s3Settings (resources controllers.FunctionResources , pulpSettings * string , customSettings map [string ]struct {}) {
385+ if _ , exists := customSettings ["STORAGES" ]; exists {
386+ return
387+ }
396388 pulp := resources .Pulp
397389 logger := resources .Logger
398390 context := resources .Context
@@ -459,9 +451,13 @@ STORAGES = {
459451}
460452
461453// tokenSettings appends the TOKEN_SERVER setting into pulpSettings
462- func tokenSettings (resources controllers.FunctionResources , pulpSettings * string ) {
454+ func tokenSettings (resources controllers.FunctionResources , pulpSettings * string , customSettings map [string ]struct {}) {
455+ if _ , exists := customSettings ["TOKEN_SERVER" ]; exists {
456+ return
457+ }
458+
463459 pulp := resources .Pulp
464- rootUrl := getRootURL (resources )
460+ rootUrl := getRootURL (* pulp )
465461
466462 // configure TOKEN_SERVER based on ingress_type
467463 tokenServer := "http://" + pulp .Name + "-api-svc." + pulp .Namespace + ".svc.cluster.local:24817/token/"
@@ -478,7 +474,11 @@ func tokenSettings(resources controllers.FunctionResources, pulpSettings *string
478474}
479475
480476// secretKeySettings appends djange SECRET_KEY setting into pulpSettings
481- func secretKeySettings (resources controllers.FunctionResources , pulpSettings * string ) {
477+ func secretKeySettings (resources controllers.FunctionResources , pulpSettings * string , customSettings map [string ]struct {}) {
478+ if _ , exists := customSettings ["SECRET_KEY" ]; exists {
479+ return
480+ }
481+
482482 pulp := resources .Pulp
483483 logger := resources .Logger
484484 pulpSecretKey := pulp .Spec .PulpSecretKey
@@ -494,7 +494,11 @@ func secretKeySettings(resources controllers.FunctionResources, pulpSettings *st
494494}
495495
496496// allowedContentChecksumsSettings appends the allowed_content_checksums into pulpSettings
497- func allowedContentChecksumsSettings (resources controllers.FunctionResources , pulpSettings * string ) {
497+ func allowedContentChecksumsSettings (resources controllers.FunctionResources , pulpSettings * string , customSettings map [string ]struct {}) {
498+ if _ , exists := customSettings ["ALLOWED_CONTENT_CHECKSUMS" ]; exists {
499+ return
500+ }
501+
498502 pulp := resources .Pulp
499503 if len (pulp .Spec .AllowedContentChecksums ) == 0 {
500504 return
@@ -503,23 +507,38 @@ func allowedContentChecksumsSettings(resources controllers.FunctionResources, pu
503507 * pulpSettings = * pulpSettings + fmt .Sprintln ("ALLOWED_CONTENT_CHECKSUMS = " , string (settings ))
504508}
505509
506- func addCustomPulpSettings (resources controllers.FunctionResources , pulpSettings * string ) {
510+ // addCustomPulpSettings defines settings.py with the configurations defined in custom_pulp_settings configmap
511+ // and returns a map with all the custom keys defined
512+ func addCustomPulpSettings (resources controllers.FunctionResources , pulpSettings * string ) map [string ]struct {} {
507513 pulp := resources .Pulp
514+ rootUrl := getRootURL (* pulp )
515+ defaultSettings := settings .DefaultPulpSettings (rootUrl )
508516
517+ // if custom_pulp_settings is not defined, append the default values and return
509518 if pulp .Spec .CustomPulpSettings == "" {
510- return
519+ for _ , k := range sortKeys (defaultSettings ) {
520+ * pulpSettings = * pulpSettings + fmt .Sprintf ("%v = %v\n " , k , defaultSettings [k ])
521+ }
522+ return nil
511523 }
512524
513525 settingsCM := & corev1.ConfigMap {}
514526 resources .Client .Get (resources .Context , types.NamespacedName {Name : pulp .Spec .CustomPulpSettings , Namespace : pulp .Namespace }, settingsCM )
515527
516- settings := ""
528+ // store the keys found in custom_pulp_settings configmap
529+ settings := map [string ]struct {}{}
517530 for _ , k := range sortKeys (settingsCM .Data ) {
518- settings = settings + fmt .Sprintf ("%v = %v\n " , strings .ToUpper (k ), settingsCM .Data [k ])
519- }
531+ * pulpSettings = * pulpSettings + fmt .Sprintf ("%v = %v\n " , strings .ToUpper (k ), settingsCM .Data [k ])
532+ settings [ strings . ToUpper ( k )] = struct {}{ }
520533
521- * pulpSettings = * pulpSettings + settings
534+ // remove the settings from defaultSettings dict to avoid duplicate config
535+ delete (defaultSettings , strings .ToUpper (k ))
536+ }
522537
538+ for _ , k := range sortKeys (defaultSettings ) {
539+ * pulpSettings = * pulpSettings + fmt .Sprintf ("%v = %v\n " , k , defaultSettings [k ])
540+ }
541+ return settings
523542}
524543
525544// debugLogging will set the log level from Pulpcore pods to DEBUG
0 commit comments