Skip to content

Commit

Permalink
Adds missing passphrase option to pull command.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Dec 7, 2024
1 parent f95dc06 commit bdef310
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/structurizr/cli/PullCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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();

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit bdef310

Please sign in to comment.