-
Notifications
You must be signed in to change notification settings - Fork 8
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
load config from System Properties if present #96
Changes from 3 commits
c64cf37
b18cf49
63de39b
a8c5c48
00b7902
9bbd773
774e223
a9a93c8
7361445
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,9 +184,44 @@ private static Properties loadProperties(File configFilePath) throws IOException | |
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(configFilePath))) { | ||
config.load(inputStream); | ||
} | ||
// override with system properties, if present | ||
config.putAll(loadSystemProperties()); | ||
return config; | ||
} | ||
|
||
private static Map<String, Object> loadSystemProperties() { | ||
Map<String, Object> systemProperties = new HashMap<>(); | ||
String reporter = getProperty(REPORTER_PROPERTY_NAME); | ||
if(reporter != null && !reporter.equals("")){ | ||
systemProperties.put(REPORTER_PROPERTY_NAME, reporter); | ||
} | ||
|
||
String accessToken = getProperty(ACCESS_TOKEN_PROPERTY_NAME); | ||
if(accessToken != null && !accessToken.equals("")){ | ||
systemProperties.put(ACCESS_TOKEN_PROPERTY_NAME, accessToken); | ||
} | ||
|
||
String apiEndpoint = getProperty(API_ENDPOINT_PROPERTY_NAME); | ||
if(apiEndpoint != null && !apiEndpoint.equals("")){ | ||
systemProperties.put(API_ENDPOINT_PROPERTY_NAME, apiEndpoint); | ||
} | ||
|
||
String globalTags = getProperty(GLOBAL_TAGS_PROPERTY_NAME); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. System prop name should be jinsight.global_tags (even though the property name is just global_tags) |
||
if(globalTags != null && !globalTags.equals("")){ | ||
systemProperties.put(GLOBAL_TAGS_PROPERTY_NAME, globalTags); | ||
} | ||
|
||
return systemProperties; | ||
} | ||
|
||
private static String getProperty(String propertyName) { | ||
String propertyValue = System.getenv(propertyName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if not propertyName.contains(".") then propertyName="jinsight."+propertyName Then all new constants GLOBAL_TAGS_SYSTEM_PROPERTY_NAME REPORTER_SYSTEM_PROPERTY_NAME etc can be deleted |
||
if(propertyValue == null || propertyValue.equals("")){ | ||
propertyValue = System.getProperty(propertyName); | ||
} | ||
return propertyValue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If propertyValue is "" return null, so that we dont have to do !="" check everywhere |
||
} | ||
|
||
private Sanitizer readSanitizer(Properties config) { | ||
String configSanitizer = config.getProperty("apptuit.sanitizer"); | ||
if (configSanitizer != null && !configSanitizer.equals("")) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System prop name should be jinsight.reporter (even though the property name is just reporter)