From 204c2958a851455f10b28fdd4c15870feec62951 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sun, 22 Feb 2026 17:31:40 +0100 Subject: [PATCH] fix: Add prefix_separator to config env override The config-rs crate uses '_' as the default prefix separator, so BARYCENTER__DATABASE__URL was parsed as _database.url instead of database.url. Adding prefix_separator("__") ensures double-underscore env vars are correctly mapped to nested config keys. Also makes the database section in the Helm ConfigMap conditional so it can be omitted when the URL is provided via environment variable. Co-Authored-By: Claude Opus 4.6 --- deploy/helm/barycenter/templates/configmap.yaml | 2 ++ src/settings.rs | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deploy/helm/barycenter/templates/configmap.yaml b/deploy/helm/barycenter/templates/configmap.yaml index 296a3df..ccefb44 100644 --- a/deploy/helm/barycenter/templates/configmap.yaml +++ b/deploy/helm/barycenter/templates/configmap.yaml @@ -13,8 +13,10 @@ data: public_base_url = {{ .Values.config.server.publicBaseUrl | quote }} {{- end }} + {{- if .Values.config.database.url }} [database] url = {{ .Values.config.database.url | quote }} + {{- end }} [keys] jwks_path = {{ .Values.config.keys.jwksPath | quote }} diff --git a/src/settings.rs b/src/settings.rs index 34901d4..66586db 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -145,8 +145,11 @@ impl Settings { } // Environment overrides: BARYCENTER__SERVER__PORT=9090, etc. - builder = - builder.add_source(config::Environment::with_prefix("BARYCENTER").separator("__")); + builder = builder.add_source( + config::Environment::with_prefix("BARYCENTER") + .prefix_separator("__") + .separator("__"), + ); let cfg = builder.build().into_diagnostic()?; let mut s: Settings = cfg.try_deserialize().into_diagnostic()?;