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

Merge server env #830

Merged
merged 4 commits into from
Jun 2, 2023
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 @@ -890,6 +890,7 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
if (serverEnvPath == null && server.serverEnvFile == null) {
// Do a special case merge but ONLY if there is no server.env file present in configDirectory or specified with serverEnvFile
envPropsToWrite = mergeSpecialPropsFromInstallServerEnvIfAbsent(envFile, configuredProps)
logger.warn("The default " + envFile.getCanonicalPath() + " file is overwritten by inlined configuration.")
} else if (serverEnvPath != null) {
logger.warn("The " + serverEnvPath + " file is overwritten by inlined configuration.")
}
Expand All @@ -911,19 +912,16 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
*/
private Properties mergeSpecialPropsFromInstallServerEnvIfAbsent(File envFile, Properties envProps) throws IOException {

String[] specialProps = { "keystore_password" }

// Make a copy to avoid side effects
Properties mergedProps = new Properties()
mergedProps.putAll(envProps)

// From install (target) dir
Properties serverEnvProps = convertServerEnvToProperties(envFile)

for (String propertyName : specialProps) {
if (serverEnvProps.containsKey(propertyName)) {
mergedProps.putIfAbsent(propertyName,serverEnvProps.get(propertyName))
}
String propertyName = "keystore_password"
if (serverEnvProps.containsKey(propertyName)) {
mergedProps.putIfAbsent(propertyName,serverEnvProps.get(propertyName))
}

return mergedProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ public class TestCreateWithInlineProperties extends AbstractIntegrationTest{

prop = new Properties();
prop.load( input2 );
assert prop.size() == 2 : "expected 2 properties in server.env file but found "+prop.size()
assert prop.size() == 3 : "expected 3 properties in server.env file but found "+prop.size()
String value2 = prop.getProperty("some.env.var");
assert value2 != null && value2.equals("someValue") : "property not found in server.env file"
assert value2 != null && value2.equals("someValue") : "some.env.var property not found in server.env file"
value2 = prop.getProperty("another.env.var");
assert value2 != null && value2.equals("anotherValue") : "property not found in server.env file"
assert value2 != null && value2.equals("anotherValue") : "another.env.var property not found in server.env file"
// if no server.env file is specified in configuration and mergeServerEnv is not set to true,
// the keystore_password is still preserved when present in the default server.env file and not specified in a property
value2 = prop.getProperty("keystore_password");
assert value2 != null : "keystore_password property not found in server.env file"

assert libertyConfigVarOverridesFile.text.contains("name=\"someVar\"") : "configDropins/overrides/liberty-plugin-variable-config.xml does not contain expected variable: "+libertyConfigVarOverridesFile.text
assert libertyConfigVarOverridesFile.text.contains("value=\"someValue\"") : "configDropins/overrides/liberty-plugin-variable-config.xml does not contain expected variable: "+libertyConfigVarOverridesFile.text
Expand Down

This file was deleted.

This file was deleted.