Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Add flag to skip loading props that don't exist when creating a new e…
Browse files Browse the repository at this point in the history
…nv (#127)
  • Loading branch information
fieldju authored Dec 6, 2018
1 parent f742013 commit 2f61981
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

group=com.nike
artifactId=cerberus-lifecycle-cli
version=4.6.3
version=4.6.4
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CreateCmsConfigOperation(final ConfigStore configStore) {
@Override
public void run(final CreateCmsConfigCommand command) {
logger.info("Retrieving configuration data from the configuration bucket.");
final Properties cmsConfigProperties = configStore.getCmsSystemProperties();
final Properties cmsConfigProperties = configStore.getCmsSystemProperties(false);

cmsConfigProperties.put(CMS_ADMIN_GROUP_KEY, command.getAdminGroup());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void run(final UpdateCmsConfigCommand command) {

logger.debug("Retrieving configuration data from the configuration bucket.");

final Properties newProperties = configStore.getCmsSystemProperties();
final Properties newProperties = configStore.getCmsSystemProperties(true);
final Properties existingCustomProperties = configStore.getExistingCmsUserProperties();
if (!command.getOverwrite()) {
// keep existing custom properties
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/com/nike/cerberus/store/ConfigStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,23 @@ private Properties generateBaseCmsSystemProperties() {
/**
* System properties not set with -P param
*/
public Properties getCmsSystemProperties() {
public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties) {

Properties properties = new Properties();
Properties existingProperties = getAllExistingCmsEnvProperties();

// overwrite any of the automatically generated properties that may have changed
existingProperties.putAll(generateBaseCmsSystemProperties());
Properties existingProperties;
if (shouldLoadExistingProperties) {
existingProperties = getAllExistingCmsEnvProperties();

existingProperties.forEach((key, value) -> {
if (SYSTEM_CONFIGURED_CMS_PROPERTIES.contains(key)) {
properties.put(key, value);
}
});
existingProperties.forEach((key, value) -> {
if (SYSTEM_CONFIGURED_CMS_PROPERTIES.contains(key)) {
properties.put(key, value);
}
});
}

// overwrite any of the automatically generated properties that may have changed
properties.putAll(generateBaseCmsSystemProperties());

if (!properties.containsKey(HASH_SALT)) {
properties.put(HASH_SALT, saltGenerator.generateSalt());
Expand Down

0 comments on commit 2f61981

Please sign in to comment.