Class ConfigUtils
java.lang.Object
ubic.gemma.core.config.ConfigUtils
Shared configuration helpers.
Implements the *_FILE indirection pattern used by Postgres, Redis, Mongo containers and by
systemd's LoadCredential= mechanism: for any env var FOO, if a sibling FOO_FILE
is set, its value is treated as a path whose contents (trimmed) become the resolved value. If
FOO_FILE is unset, fall back to FOO directly.
This lets a podman Quadlet on Rocky Linux do:
[Service]
LoadCredential=db.password:/etc/gemma/db.password
Environment=GEMMA_DB_PASSWORD_FILE=%d/db.password
and have the Java side pick the secret up without it ever appearing in process env or
systemctl show output.
Failure is fail-fast: a _FILE pointer to a missing or unreadable file throws
IllegalStateException at startup rather than silently falling through to the bare env var.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSuffix appended to an env-var name to indicate "value lives in this file on disk". -
Method Summary
Modifier and TypeMethodDescriptionstatic StringresolveEnvVar(String name) Resolve an environment variable, honouring the*_FILEindirection pattern.static StringresolveEnvVar(String name, Function<String, String> envSource) Test-friendly form: resolve against an arbitrary env source instead ofSystem.getenv().
-
Field Details
-
FILE_INDIRECTION_SUFFIX
Suffix appended to an env-var name to indicate "value lives in this file on disk".- See Also:
-
-
Method Details
-
resolveEnvVar
Resolve an environment variable, honouring the*_FILEindirection pattern.- Parameters:
name- env-var name, e.g.GEMMA_DB_PASSWORD- Returns:
- the resolved value (from
<name>_FILEcontents if set, else from<name>), ornullif neither is set - Throws:
IllegalStateException- if<name>_FILEis set but the file cannot be read
-
resolveEnvVar
-