From 24eb3aa3571f7f51e3cabca03076afd145c39dd3 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 30 Oct 2024 13:09:50 -0400 Subject: [PATCH] Fix doSystemAndReleaseMatch to handle arm64 (#53) --- .../terrakube/terraform/TerraformDownloader.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/terraform-client/src/main/java/org/terrakube/terraform/TerraformDownloader.java b/terraform-client/src/main/java/org/terrakube/terraform/TerraformDownloader.java index 931f91c..1520f71 100644 --- a/terraform-client/src/main/java/org/terrakube/terraform/TerraformDownloader.java +++ b/terraform-client/src/main/java/org/terrakube/terraform/TerraformDownloader.java @@ -214,11 +214,7 @@ private String downloadFileOrReturnPathIfAlreadyExists(String fileName, String z } private boolean doSystemAndReleaseMatch(String arch, String os) { - return arch.equals(SystemUtils.OS_ARCH) - && (SystemUtils.IS_OS_WINDOWS && os.equals("windows") || - SystemUtils.IS_OS_LINUX && os.equals("linux")) - || - SystemUtils.IS_OS_MAC && os.equals("darwin"); + return arch.equals(this.getArch()) && os.equals(this.getOs()); } public String downloadTerraformVersion(String terraformVersion) throws IOException { @@ -294,6 +290,16 @@ public String getOs() { return "linux"; } + private String getArch() { + if (SystemUtils.OS_ARCH == null) { + throw new IllegalArgumentException("System architecture not detected"); + } + if (SystemUtils.OS_ARCH.equals("aarch64")) { + return "arm64"; + } + return SystemUtils.OS_ARCH; + } + private String unzipTerraformVersion(String terraformVersion, File terraformZipFile) throws IOException { createVersionDirectory(terraformVersion, TERRAFORM_DIRECTORY); String newFilePath = null;