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

Commit 04f3983

Browse files
BrunoCarrierfieldju
authored andcommitted
Added an option flag to ignore default CMS properties when updating CMS 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
1 parent 3733402 commit 04f3983

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
group=com.nike
1818
artifactId=cerberus-lifecycle-cli
19-
version=4.7.0
19+
version=4.7.1

src/main/java/com/nike/cerberus/command/cms/UpdateCmsConfigCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class UpdateCmsConfigCommand implements Command {
3737
public static final String COMMAND_NAME = "update-cms-config";
3838
public static final String OVERWRITE_LONG_ARG = "--overwrite";
3939
public static final String FORCE_ARG = "--force";
40+
public static final String IGNORE_DEFAULT_CONFIGURATIONS_ARGUMENT = "--ignore-default-configurations";
4041

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

54+
@Parameter(names = IGNORE_DEFAULT_CONFIGURATIONS_ARGUMENT, description = "Ignores default configurations of the CMS. ")
55+
private boolean ignoreDefaultConfigurations = false;
56+
5357
public String getAdminGroup() {
5458
return adminGroup;
5559
}
@@ -66,6 +70,10 @@ public boolean isForce() {
6670
return force;
6771
}
6872

73+
public boolean isIgnoreDefaultConfigurations() {
74+
return ignoreDefaultConfigurations;
75+
}
76+
6977
@Override
7078
public String getCommandName() {
7179
return COMMAND_NAME;

src/main/java/com/nike/cerberus/operation/cms/CreateCmsConfigOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public CreateCmsConfigOperation(final ConfigStore configStore) {
4444
@Override
4545
public void run(final CreateCmsConfigCommand command) {
4646
logger.info("Retrieving configuration data from the configuration bucket.");
47-
final Properties cmsConfigProperties = configStore.getCmsSystemProperties(false);
47+
final Properties cmsConfigProperties = configStore.getCmsSystemProperties(false, false);
4848

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

src/main/java/com/nike/cerberus/operation/cms/UpdateCmsConfigOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void run(final UpdateCmsConfigCommand command) {
4949

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

52-
final Properties newProperties = configStore.getCmsSystemProperties(true);
52+
final Properties newProperties = configStore.getCmsSystemProperties(true, command.isIgnoreDefaultConfigurations());
5353
final Properties existingCustomProperties = configStore.getExistingCmsUserProperties();
5454
if (!command.getOverwrite()) {
5555
// keep existing custom properties

src/main/java/com/nike/cerberus/store/ConfigStore.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ private Properties generateBaseCmsSystemProperties() {
324324
/**
325325
* System properties not set with -P param
326326
*/
327-
public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties) {
328-
327+
public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties, boolean shouldIgnoreDefaultCmsProperties) {
329328
Properties properties = new Properties();
330329

331330
Properties existingProperties;
@@ -339,8 +338,10 @@ public Properties getCmsSystemProperties(boolean shouldLoadExistingProperties) {
339338
});
340339
}
341340

342-
// overwrite any of the automatically generated properties that may have changed
343-
properties.putAll(generateBaseCmsSystemProperties());
341+
if (!shouldIgnoreDefaultCmsProperties) {
342+
// overwrite any of the automatically generated properties that may have changed
343+
properties.putAll(generateBaseCmsSystemProperties());
344+
}
344345

345346
if (!properties.containsKey(HASH_SALT)) {
346347
properties.put(HASH_SALT, saltGenerator.generateSalt());

0 commit comments

Comments
 (0)