From f6f63c3f54f731b3042ea4044539c4d5e6759f4c Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:33:03 +0000 Subject: [PATCH] Set up arguments in DeployExistingInstance --- .../deploy/DeployExistingInstance.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/java/clients/src/main/java/sleeper/clients/deploy/DeployExistingInstance.java b/java/clients/src/main/java/sleeper/clients/deploy/DeployExistingInstance.java index bb831d1f64..047122abbf 100644 --- a/java/clients/src/main/java/sleeper/clients/deploy/DeployExistingInstance.java +++ b/java/clients/src/main/java/sleeper/clients/deploy/DeployExistingInstance.java @@ -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(); @@ -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 = S3TableProperties.createStore(instanceProperties, s3, dynamoDB) @@ -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;