From 0a7391db90acd0cf20158346c4d7c37047d06971 Mon Sep 17 00:00:00 2001 From: Justin Field Date: Tue, 10 Apr 2018 14:57:25 -0700 Subject: [PATCH] add flag for skipping ami check that got dropped during refactor (#122) --- gradle.properties | 2 +- .../cerberus/command/core/UpdateStackCommand.java | 11 ++++++++++- .../cerberus/operation/core/UpdateStackOperation.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3e43d06a..dcbfb7e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ group=com.nike artifactId=cerberus-lifecycle-cli -version=4.6.0 +version=4.6.1 diff --git a/src/main/java/com/nike/cerberus/command/core/UpdateStackCommand.java b/src/main/java/com/nike/cerberus/command/core/UpdateStackCommand.java index e6be80e0..c3b7048f 100644 --- a/src/main/java/com/nike/cerberus/command/core/UpdateStackCommand.java +++ b/src/main/java/com/nike/cerberus/command/core/UpdateStackCommand.java @@ -31,7 +31,8 @@ import java.util.Map; import static com.nike.cerberus.command.core.UpdateStackCommand.COMMAND_NAME; - +import static com.nike.cerberus.ConfigConstants.SKIP_AMI_TAG_CHECK_ARG; +import static com.nike.cerberus.ConfigConstants.SKIP_AMI_TAG_CHECK_DESCRIPTION; /** * Command for updating the specified CloudFormation stack with the new parameters. @@ -78,6 +79,14 @@ public String getCommandName() { return COMMAND_NAME; } + @Parameter(names = SKIP_AMI_TAG_CHECK_ARG, + description = SKIP_AMI_TAG_CHECK_DESCRIPTION) + private boolean skipAmiTagCheck; + + public boolean isSkipAmiTagCheck() { + return skipAmiTagCheck; + } + @Override public Class> getOperationClass() { return UpdateStackOperation.class; diff --git a/src/main/java/com/nike/cerberus/operation/core/UpdateStackOperation.java b/src/main/java/com/nike/cerberus/operation/core/UpdateStackOperation.java index b182dd10..a7e9906e 100644 --- a/src/main/java/com/nike/cerberus/operation/core/UpdateStackOperation.java +++ b/src/main/java/com/nike/cerberus/operation/core/UpdateStackOperation.java @@ -76,7 +76,7 @@ public void run(UpdateStackCommand command) { Optional.ofNullable(tags.getOrDefault("ownerGroup", null)))); } - if (Stack.CMS.equals(command.getStack())) { + if (Stack.CMS.equals(command.getStack()) && ! command.isSkipAmiTagCheck()) { command.getDynamicParameters().forEach((key, value) -> { if (key.equals("amiId")) { amiTagCheckService.validateAmiTagForStack(value, Stack.CMS);