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 <noreply@anthropic.com>
This commit is contained in:
Till Wegmueller 2026-02-22 17:31:40 +01:00
parent 8d835e240b
commit 204c2958a8
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -13,8 +13,10 @@ data:
public_base_url = {{ .Values.config.server.publicBaseUrl | quote }} public_base_url = {{ .Values.config.server.publicBaseUrl | quote }}
{{- end }} {{- end }}
{{- if .Values.config.database.url }}
[database] [database]
url = {{ .Values.config.database.url | quote }} url = {{ .Values.config.database.url | quote }}
{{- end }}
[keys] [keys]
jwks_path = {{ .Values.config.keys.jwksPath | quote }} jwks_path = {{ .Values.config.keys.jwksPath | quote }}

View file

@ -145,8 +145,11 @@ impl Settings {
} }
// Environment overrides: BARYCENTER__SERVER__PORT=9090, etc. // Environment overrides: BARYCENTER__SERVER__PORT=9090, etc.
builder = builder = builder.add_source(
builder.add_source(config::Environment::with_prefix("BARYCENTER").separator("__")); config::Environment::with_prefix("BARYCENTER")
.prefix_separator("__")
.separator("__"),
);
let cfg = builder.build().into_diagnostic()?; let cfg = builder.build().into_diagnostic()?;
let mut s: Settings = cfg.try_deserialize().into_diagnostic()?; let mut s: Settings = cfg.try_deserialize().into_diagnostic()?;