From bdef3107c9d660b68f50796e2fc1766b1604bbf8 Mon Sep 17 00:00:00 2001 From: Simon Brown <1009874+simonbrowndotje@users.noreply.github.com> Date: Sat, 7 Dec 2024 10:39:31 +0000 Subject: [PATCH] Adds missing passphrase option to pull command. --- src/main/java/com/structurizr/cli/PullCommand.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/structurizr/cli/PullCommand.java b/src/main/java/com/structurizr/cli/PullCommand.java index 171689a..3af4c51 100644 --- a/src/main/java/com/structurizr/cli/PullCommand.java +++ b/src/main/java/com/structurizr/cli/PullCommand.java @@ -2,6 +2,7 @@ import com.structurizr.Workspace; import com.structurizr.api.WorkspaceApiClient; +import com.structurizr.encryption.AesEncryptionStrategy; import com.structurizr.util.StringUtils; import com.structurizr.util.WorkspaceUtils; import org.apache.commons.cli.*; @@ -40,6 +41,10 @@ public void run(String... args) throws Exception { option.setRequired(false); options.addOption(option); + option = new Option("passphrase", "passphrase", true, "Client-side encryption passphrase"); + option.setRequired(false); + options.addOption(option); + CommandLineParser commandLineParser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); @@ -48,6 +53,7 @@ public void run(String... args) throws Exception { String apiKey = ""; String apiSecret = ""; String branch = ""; + String passphrase = ""; try { CommandLine cmd = commandLineParser.parse(options, args); @@ -57,6 +63,7 @@ public void run(String... args) throws Exception { apiKey = cmd.getOptionValue("apiKey"); apiSecret = cmd.getOptionValue("apiSecret"); branch = cmd.getOptionValue("branch"); + passphrase = cmd.getOptionValue("passphrase"); } catch (ParseException e) { log.error(e.getMessage()); formatter.printHelp("pull", options); @@ -76,6 +83,12 @@ public void run(String... args) throws Exception { WorkspaceApiClient client = new WorkspaceApiClient(apiUrl, apiKey, apiSecret); client.setBranch(branch); client.setAgent(getAgent()); + + if (!StringUtils.isNullOrEmpty(passphrase)) { + log.info(" - using client-side encryption"); + client.setEncryptionStrategy(new AesEncryptionStrategy(passphrase)); + } + Workspace workspace = client.getWorkspace(workspaceId); WorkspaceUtils.saveWorkspaceToJson(workspace, file);