Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #2334 make convertEnvVars configurable to work with lower case … #2335

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class ConfigInjection {
private static final String SCALABLE_CONFIG = "config";
private static final String EXCLUSION_CONFIG_FILE_LIST = "exclusionConfigFileList";
private static final String ALLOW_DEFAULT_EMPTY = "allowDefaultValueEmpty";
private static final String CONVERT_ENV_VARS = "convertEnvVars";

private static final Map<String, Object> exclusionMap = Config.getInstance().getJsonMapConfig(SCALABLE_CONFIG);

Expand Down Expand Up @@ -107,6 +108,10 @@ static String convertEnvVars(String input){
if (input == null) {
return null;
}
if (exclusionMap.get(CONVERT_ENV_VARS) != null && !(Boolean)exclusionMap.get(CONVERT_ENV_VARS)) {
// only if the flag is set to false, then don't convert.
return input;
}
return input.replaceAll("[^A-Za-z0-9]", "_").toUpperCase();
}

Expand Down
6 changes: 6 additions & 0 deletions config/src/main/resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ decryptorClass: com.networknt.decrypt.AutoAESSaltDecryptor
# would be negative impact on the application security. The following config will ensure that
# null will be used when the default value is empty without stopping the server during the start.
allowDefaultValueEmpty: true

# For some operating systems, environment variable can be only upper case, to make sure they can
# match the key defined in each config files, we can convert the env vars to upper case to match.
# The default value is true, and it will cover most operating systems (Linux and Windows). Change
# this value to false if you have lower or mix case environment variable names.
convertEnvVars: true