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

Commit

Permalink
Added an option flag to ignore default CMS properties when updating C…
Browse files Browse the repository at this point in the history
…MS properties (#129)

* Added an option flag to ignore default CMS properties when updating CMS properties

* Incremented the version

* Removed debug statements that aren't relevant in production
  • Loading branch information
BrunoCarrier authored and fieldju committed Dec 19, 2018
1 parent 3733402 commit 04f3983
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 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.7.0
version=4.7.1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class UpdateCmsConfigCommand implements Command {
public static final String COMMAND_NAME = "update-cms-config";
public static final String OVERWRITE_LONG_ARG = "--overwrite";
public static final String FORCE_ARG = "--force";
public static final String IGNORE_DEFAULT_CONFIGURATIONS_ARGUMENT = "--ignore-default-configurations";

@Parameter(names = CreateCmsConfigCommand.ADMIN_GROUP_LONG_ARG, description = "Group that has admin privileges in CMS.")
private String adminGroup;
Expand All @@ -50,6 +51,9 @@ public class UpdateCmsConfigCommand implements Command {
@Parameter(names = FORCE_ARG, description = "Force allow overwriting of system generated property. This may break your configuration.")
private boolean force = false;

@Parameter(names = IGNORE_DEFAULT_CONFIGURATIONS_ARGUMENT, description = "Ignores default configurations of the CMS. ")
private boolean ignoreDefaultConfigurations = false;

public String getAdminGroup() {
return adminGroup;
}
Expand All @@ -66,6 +70,10 @@ public boolean isForce() {
return force;
}

public boolean isIgnoreDefaultConfigurations() {
return ignoreDefaultConfigurations;
}

@Override
public String getCommandName() {
return COMMAND_NAME;
Expand Down
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(false);
final Properties cmsConfigProperties = configStore.getCmsSystemProperties(false, 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(true);
final Properties newProperties = configStore.getCmsSystemProperties(true, command.isIgnoreDefaultConfigurations());
final Properties existingCustomProperties = configStore.getExistingCmsUserProperties();
if (!command.getOverwrite()) {
// keep existing custom properties
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/nike/cerberus/store/ConfigStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ private Properties generateBaseCmsSystemProperties() {
/**
* System properties not set with -P param
*/
public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties) {

public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties, boolean shouldIgnoreDefaultCmsProperties) {
Properties properties = new Properties();

Properties existingProperties;
Expand All @@ -339,8 +338,10 @@ public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties) {
});
}

// overwrite any of the automatically generated properties that may have changed
properties.putAll(generateBaseCmsSystemProperties());
if (!shouldIgnoreDefaultCmsProperties) {
// 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 04f3983

Please sign in to comment.