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

Commit

Permalink
Remove ami tag check logic and don't run x-region config validation w…
Browse files Browse the repository at this point in the history
…hen the environment doesn't exist (#128)
  • Loading branch information
fieldju authored Dec 11, 2018
1 parent 2f61981 commit 3733402
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 284 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.4
version=4.7.0
7 changes: 5 additions & 2 deletions src/main/java/com/nike/cerberus/cli/CerberusRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ch.qos.logback.classic.Level;
import com.beust.jcommander.JCommander;
import com.github.tomaslanger.chalk.Chalk;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.inject.Guice;
import com.google.inject.Injector;
Expand Down Expand Up @@ -131,7 +132,9 @@ public void run(String[] args) {
validator.validate();

ConfigStore configStore = injector.getInstance(ConfigStore.class);
if (!cerberusCommand.isSkipDataCheck() && !configStore.isConfigSynchronized()){
if (!ImmutableList.of(CreateEnvironmentCommand.COMMAND_NAME, InitializeEnvironmentCommand.COMMAND_NAME)
.contains(commandName) && !cerberusCommand.isSkipDataCheck() && !configStore.isConfigSynchronized()) {

ConsoleService consoleService = injector.getInstance(ConsoleService.class);
String msg = "The config buckets are out of sync between regions. Do you wish to proceed?";
if (cerberusCommand.isTty()) {
Expand Down Expand Up @@ -274,4 +277,4 @@ public static void main(String[] args) {
CerberusRunner runner = new CerberusRunner();
runner.run(args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@

package com.nike.cerberus.command.cms;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.nike.cerberus.command.Command;
import com.nike.cerberus.command.StackDelegate;
import com.nike.cerberus.operation.Operation;
import com.nike.cerberus.operation.cms.CreateCmsClusterOperation;

import static com.nike.cerberus.ConfigConstants.SKIP_AMI_TAG_CHECK_ARG;
import static com.nike.cerberus.ConfigConstants.SKIP_AMI_TAG_CHECK_DESCRIPTION;
import static com.nike.cerberus.command.cms.CreateCmsClusterCommand.COMMAND_NAME;

/**
Expand All @@ -48,16 +45,8 @@ 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<? extends Operation<?>> getOperationClass() {
return CreateCmsClusterOperation.class;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.nike.cerberus.domain.environment.CertificateInformation;
import com.nike.cerberus.domain.environment.Stack;
import com.nike.cerberus.operation.Operation;
import com.nike.cerberus.service.AmiTagCheckService;
import com.nike.cerberus.service.CloudFormationService;
import com.nike.cerberus.service.Ec2UserDataService;
import com.nike.cerberus.store.ConfigStore;
Expand All @@ -49,8 +48,6 @@ public class CreateCmsClusterOperation implements Operation<CreateCmsClusterComm

private final Ec2UserDataService ec2UserDataService;

private final AmiTagCheckService amiTagCheckService;

private final ConfigStore configStore;

private final CloudFormationObjectMapper cloudFormationObjectMapper;
Expand All @@ -60,15 +57,13 @@ public class CreateCmsClusterOperation implements Operation<CreateCmsClusterComm
@Inject
public CreateCmsClusterOperation(CloudFormationService cloudFormationService,
Ec2UserDataService ec2UserDataService,
AmiTagCheckService amiTagCheckService,
ConfigStore configStore,
CloudFormationObjectMapper cloudFormationObjectMapper,
@Named(ENV_NAME) String environmentName) {

this.environmentName = environmentName;
this.cloudFormationService = cloudFormationService;
this.ec2UserDataService = ec2UserDataService;
this.amiTagCheckService = amiTagCheckService;
this.configStore = configStore;
this.cloudFormationObjectMapper = cloudFormationObjectMapper;
}
Expand All @@ -84,11 +79,6 @@ public void run(CreateCmsClusterCommand command) {
throw new IllegalStateException("Certificate for cerberus environment has not been uploaded!");
}

// Make sure the given AmiId is for CMS component. Check if it contains required tag
if (!command.isSkipAmiTagCheck()) {
amiTagCheckService.validateAmiTagForStack(command.getStackDelegate().getAmiId(), Stack.CMS);
}

CmsParameters cmsParameters = new CmsParameters()
.setVpcSubnetIdForAz1(vpcOutputs.getVpcSubnetIdForAz1())
.setVpcSubnetIdForAz2(vpcOutputs.getVpcSubnetIdForAz2())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.nike.cerberus.command.core.UpdateStackCommand;
import com.nike.cerberus.domain.environment.Stack;
import com.nike.cerberus.operation.Operation;
import com.nike.cerberus.service.AmiTagCheckService;
import com.nike.cerberus.service.CloudFormationService;
import com.nike.cerberus.service.Ec2UserDataService;
import com.nike.cerberus.store.ConfigStore;
Expand All @@ -47,19 +46,16 @@ public class UpdateStackOperation implements Operation<UpdateStackCommand> {
private final Ec2UserDataService ec2UserDataService;
private final String environmentName;
private final ConfigStore configStore;
private final AmiTagCheckService amiTagCheckService;

@Inject
public UpdateStackOperation(CloudFormationService cloudFormationService,
Ec2UserDataService ec2UserDataService,
@Named(ENV_NAME) String environmentName,
AmiTagCheckService amiTagCheckService,
ConfigStore configStore) {

this.cloudFormationService = cloudFormationService;
this.ec2UserDataService = ec2UserDataService;
this.environmentName = environmentName;
this.amiTagCheckService = amiTagCheckService;
this.configStore = configStore;
}

Expand All @@ -76,13 +72,7 @@ public void run(UpdateStackCommand command) {
Optional.ofNullable(tags.getOrDefault("ownerGroup", null))));
}

if (Stack.CMS.equals(command.getStack()) && ! command.isSkipAmiTagCheck()) {
command.getDynamicParameters().forEach((key, value) -> {
if (key.equals("amiId")) {
amiTagCheckService.validateAmiTagForStack(value, Stack.CMS);
}
});
} else if (Stack.DATABASE.equals(command.getStack())) {
if (Stack.DATABASE.equals(command.getStack())) {
Optional<String> dbPasswordOverwrite = command.getDynamicParameters().entrySet().stream()
.filter(entry -> entry.getKey().equals("cmsDbMasterPassword"))
.map(Map.Entry::getValue)
Expand Down Expand Up @@ -141,4 +131,4 @@ public boolean isRunnable(UpdateStackCommand command) {

return isRunnable;
}
}
}
98 changes: 0 additions & 98 deletions src/main/java/com/nike/cerberus/service/AmiTagCheckService.java

This file was deleted.

Loading

0 comments on commit 3733402

Please sign in to comment.