Skip to content

Commit

Permalink
[Minor] Use configuration.getSecret() where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Jul 28, 2023
1 parent d215355 commit 4c62cf8
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Map<String, DataSource> build() {

String dbUrl = getConfigString(dbUrlKey, dbUseEnv);
String username = getConfigString(dbUsernameKey, dbUseEnv);
String password = getConfigString(dbPasswordKey, dbUseEnv);
String password = getConfigString(dbPasswordKey, dbUseEnv, true);

if (this.configuration.getBoolean(PROP_DB_ALLOW_HOST_OVERRIDE_ENV, false) //
&& System.getProperties().containsKey(PROP_DB_HOST_OVERRIDE)) {
Expand All @@ -89,8 +89,7 @@ public Map<String, DataSource> build() {

// find any pool configuration values
Map<String, String> properties = dbUseEnv ? System.getenv() : this.configuration.getAsMap();
String dbPoolPrefix = dbUseEnv ?
PROP_DB_POOL_PREFIX.replace(DOT, UNDERLINE).toUpperCase() :
String dbPoolPrefix = dbUseEnv ? PROP_DB_POOL_PREFIX.replace(DOT, UNDERLINE).toUpperCase() :
PROP_DB_POOL_PREFIX;
Properties props = new Properties();
for (String key : properties.keySet()) {
Expand Down Expand Up @@ -128,8 +127,15 @@ public Map<String, DataSource> build() {
}

private String getConfigString(String dbKey, boolean useEnv) {
if (!useEnv)
return getConfigString(dbKey, useEnv, false);
}

private String getConfigString(String dbKey, boolean useEnv, boolean isSecret) {
if (!useEnv) {
if (isSecret)
return this.configuration.getSecret(dbKey);
return this.configuration.getString(dbKey, null);
}

String value = System.getenv(dbKey);
if (isEmpty(value))
Expand Down

0 comments on commit 4c62cf8

Please sign in to comment.