Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 9482806

Browse files
authored
fix(vault): fix version fetching logic (#172)
1 parent 407738b commit 9482806

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

bun.lockb

-7 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"devDependencies": {
1111
"bun-types": "^1.0.18",
1212
"gray-matter": "^4.0.3",
13-
"marked": "^11.1.0",
13+
"marked": "^12.0.0",
1414
"prettier-plugin-sh": "^0.13.1",
1515
"prettier-plugin-terraform-formatter": "^1.2.1"
1616
},

vault-github/main.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe } from "bun:test";
22
import { runTerraformInit, testRequiredVariables } from "../test";
33

4-
describe("vault-token", async () => {
4+
describe("vault-github", async () => {
55
await runTerraformInit(import.meta.dir);
66

77
testRequiredVariables(import.meta.dir, {

vault-github/run.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@ unzip_safe() {
3232
}
3333

3434
install() {
35+
# Get the architecture of the system
36+
ARCH=$(uname -m)
37+
if [ "$${ARCH}" = "x86_64" ]; then
38+
ARCH="amd64"
39+
elif [ "$${ARCH}" = "aarch64" ]; then
40+
ARCH="arm64"
41+
else
42+
printf "Unsupported architecture: $${ARCH}\n"
43+
return 1
44+
fi
3545
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest'
3646
if [ "$${INSTALL_VERSION}" = "latest" ]; then
37-
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v '-rc' | grep -oP 'vault/\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
47+
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v 'rc' | grep -oE 'vault/[0-9]+\.[0-9]+\.[0-9]+' | sed 's/vault\///' | sort -V | tail -n 1)
3848
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
3949
if [ -z "$${LATEST_VERSION}" ]; then
4050
printf "Failed to determine the latest Vault version.\n"
@@ -60,7 +70,7 @@ install() {
6070
else
6171
printf "Upgrading Vault CLI from version %s to %s ...\n\n" "$${CURRENT_VERSION}" "${INSTALL_VERSION}"
6272
fi
63-
fetch vault.zip "https://releases.hashicorp.com/vault/$${INSTALL_VERSION}/vault_$${INSTALL_VERSION}_linux_amd64.zip"
73+
fetch vault.zip "https://releases.hashicorp.com/vault/$${INSTALL_VERSION}/vault_$${INSTALL_VERSION}_linux_$${ARCH}.zip"
6474
if [ $? -ne 0 ]; then
6575
printf "Failed to download Vault.\n"
6676
return 1

vault-token/run.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,19 @@ unzip_safe() {
3030
}
3131

3232
install() {
33+
# Get the architecture of the system
34+
ARCH=$(uname -m)
35+
if [ "$${ARCH}" = "x86_64" ]; then
36+
ARCH="amd64"
37+
elif [ "$${ARCH}" = "aarch64" ]; then
38+
ARCH="arm64"
39+
else
40+
printf "Unsupported architecture: $${ARCH}\n"
41+
return 1
42+
fi
3343
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest'
3444
if [ "$${INSTALL_VERSION}" = "latest" ]; then
35-
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v '-rc' | grep -oP 'vault/\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
45+
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v 'rc' | grep -oE 'vault/[0-9]+\.[0-9]+\.[0-9]+' | sed 's/vault\///' | sort -V | tail -n 1)
3646
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
3747
if [ -z "$${LATEST_VERSION}" ]; then
3848
printf "Failed to determine the latest Vault version.\n"

0 commit comments

Comments
 (0)