Add support to override properties trough env vars
This commit is contained in:
@@ -14,6 +14,7 @@ import javax.annotation.Nonnull;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -159,13 +160,21 @@ public class HapiProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getProperty(String propertyName) {
|
private static String getProperty(String propertyName) {
|
||||||
Properties properties = HapiProperties.getProperties();
|
String env = "HAPI_" + propertyName.toUpperCase(Locale.US);
|
||||||
|
env = env.replace(".", "_");
|
||||||
|
env = env.replace("-", "_");
|
||||||
|
|
||||||
if (properties != null) {
|
String propertyValue = System.getenv(env);
|
||||||
return properties.getProperty(propertyName);
|
if (propertyValue != null) {
|
||||||
|
return propertyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
Properties properties = HapiProperties.getProperties();
|
||||||
|
if (properties != null) {
|
||||||
|
propertyValue = properties.getProperty(propertyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return propertyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getProperty(String propertyName, String defaultValue) {
|
private static String getProperty(String propertyName, String defaultValue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user