Skip to content

Commit

Permalink
Set up arguments in DeployExistingInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
patchwork01 committed Nov 1, 2024
1 parent bbe57de commit f6f63c3
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ public static void main(String[] args) throws IOException, InterruptedException
EcrClient ecr = EcrClient.create()) {
builder().clients(s3v2, ecr)
.scriptsDirectory(Path.of(args[0]))
.deployInstanceConfiguration(loadConfigFromS3(args[1], s3, dynamoDB))
.deployCommand(optionalArgument(args, 3)
.deployInstanceConfiguration(optionalArgument(args, 2)
.map(Path::of)
.map(instancePropertiesFile -> mergeLocalWithConfigFromS3(args[1], instancePropertiesFile, s3, dynamoDB))
.orElseGet(() -> loadConfigFromS3(args[1], s3, dynamoDB)))
.deployPaused(optionalArgument(args, 3)
.map(Boolean::parseBoolean)
.orElse(false) ? deployExistingPaused() : deployExisting())
.orElse(false))
.build().update();
} finally {
s3.shutdown();
Expand Down Expand Up @@ -133,6 +136,13 @@ public void update() throws IOException, InterruptedException {
LOGGER.info("Finished deployment of existing instance");
}

private static DeployInstanceConfiguration mergeLocalWithConfigFromS3(
String instanceId, Path instancePropertiesFile, AmazonS3 s3, AmazonDynamoDB dynamoDB) {
DeployInstanceConfiguration config = loadConfigFromS3(instanceId, s3, dynamoDB);
// TODO reset properties to local configuration
return config;
}

private static DeployInstanceConfiguration loadConfigFromS3(String instanceId, AmazonS3 s3, AmazonDynamoDB dynamoDB) {
InstanceProperties instanceProperties = S3InstanceProperties.loadGivenInstanceId(s3, instanceId);
List<TableProperties> tableProperties = S3TableProperties.createStore(instanceProperties, s3, dynamoDB)
Expand Down Expand Up @@ -172,6 +182,10 @@ public Builder deployCommand(CdkDeploy deployCommand) {
return this;
}

public Builder deployPaused(boolean deployPaused) {
return deployCommand(deployPaused ? deployExistingPaused() : deployExisting());
}

public Builder runCommand(CommandPipelineRunner runCommand) {
this.runCommand = runCommand;
return this;
Expand Down

0 comments on commit f6f63c3

Please sign in to comment.