Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement multi-arch support #183

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:
argocd: ./**/argocd/**
atlas: ./**/atlas/**
bicep: ./**/bicep/**
binaryen: ./**/binaryen/**
calicoctl: ./**/calicoctl/**
cilium: ./**/cilium/**
clusterctl: ./**/clusterctl/**
deno: ./**/deno/**
flux: ./**/flux/**
func: ./**/func/**
gcloud: ./**/gcloud/**
helm: ./**/helm/**
istioctl: ./**/istioctl/**
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ jobs:
- argocd
- atlas
- bicep
- binaryen
- calicoctl
- cilium
- clusterctl
- deno
- flux
- func
- gcloud
- helm
- istioctl
Expand Down
4 changes: 2 additions & 2 deletions src/argocd/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "argocd",
"version": "1.1.3",
"version": "1.2.0",
"name": "Argo CD",
"description": "Command line tool (argo-cd)",
"documentationURL": "https://argo-cd.readthedocs.io",
Expand All @@ -12,4 +12,4 @@
}
},
"customizations": {}
}
}
92 changes: 68 additions & 24 deletions src/argocd/install.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,95 @@
#!/bin/sh
#!/bin/bash
set -e

cd "$(mktemp -d)"

check() {
log() {
local LEVEL="$1"
shift
echo "[$LEVEL] $*"
}

check_deps() {
log "INFO" "Checking required dependencies: $*"
export DEBIAN_FRONTEND=noninteractive

if ! dpkg -s "$@" > /dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt update..."
if [ ! -f /var/lib/apt/lists/lock ]; then
log "INFO" "Running apt update..."
apt update -y
fi
log "INFO" "Installing missing dependencies: $*"
apt -y install --no-install-recommends "$@"
else
log "INFO" "All required dependencies are already installed."
fi
}

export DEBIAN_FRONTEND=noninteractive
check_deps curl ca-certificates jq

check curl ca-certificates jq
get_version() {
VERSION="${VERSION:-latest}"

version() {
if [ "${VERSION}" = "latest" ]; then
if [ "$VERSION" = "latest" ]; then
log "INFO" "Fetching latest ArgoCD version from GitHub..."
URL="https://api.github.com/repos/argoproj/argo-cd/releases/latest"
if ! curl -sLf -o ./response.json "$URL"; then
echo "ERROR: Unable to fetch latest version"

if ! curl -sLf --fail -o ./response.json "$URL"; then
log "ERROR" "Unable to fetch latest version from GitHub API!"
exit 1
fi
export VERSION=$(cat ./response.json | jq -r ".tag_name" | sed 's/v//')

VERSION=$(jq -r ".tag_name" < ./response.json | sed 's/v//')
log "INFO" "Latest version found: v$VERSION"
else
export VERSION=$(echo ${VERSION} | sed 's/v//')
VERSION=$(echo "$VERSION" | sed 's/v//')
log "INFO" "Using specified version: v$VERSION"
fi

export VERSION
}

download() {
URL="https://github.com/argoproj/argo-cd/releases/download/v"${VERSION}"/argocd-linux-amd64"
if ! curl -sLf -o ./argocd "$URL"; then
echo "ERROR: Unable to download file"
detect_arch() {
log "INFO" "Detecting system architecture..."

case "$(uname -m)" in
x86_64 | amd64) ARCH="amd64" ;;
aarch64 | arm64) ARCH="arm64" ;;
*) log "ERROR" "Unsupported architecture: $(uname -m)"; exit 1 ;;
esac

log "INFO" "Architecture detected: $ARCH"
export ARCH
}

download_binary() {
if [ -z "$VERSION" ] || [ -z "$ARCH" ]; then
log "ERROR" "Missing version or architecture information!"
exit 1
fi

URL="https://github.com/argoproj/argo-cd/releases/download/v${VERSION}/argocd-linux-${ARCH}"
log "INFO" "Downloading ArgoCD binary from $URL"

if ! curl -sLf --fail -o ./argocd "$URL"; then
log "ERROR" "Failed to download ArgoCD binary!"
exit 1
fi

log "INFO" "Download complete!"
}

install() {
chmod +x ./argocd
chown root:root ./argocd
mv ./argocd /usr/local/bin/argocd
install_binary() {
log "INFO" "Installing ArgoCD..."
install -m 0755 ./argocd /usr/local/bin/argocd
log "INFO" "ArgoCD installed successfully to /usr/local/bin/argocd"
}

echo "Activating feature 'argocd'"
log "INFO" "Activating feature 'argocd'"

get_version
detect_arch
download_binary
install_binary

version
download
install
log "INFO" "Installation complete!"
4 changes: 2 additions & 2 deletions src/atlas/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "atlas",
"version": "1.0.0",
"version": "1.1.0",
"name": "Atlas CLI",
"description": "Command line tool (atlas)",
"documentationURL": "https://www.mongodb.com/docs/atlas/cli/current/",
Expand All @@ -18,4 +18,4 @@
]
}
}
}
}
98 changes: 66 additions & 32 deletions src/atlas/install.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,97 @@
#!/bin/sh
#!/bin/bash
set -e

cd "$(mktemp -d)"

check() {
log() {
local LEVEL="$1"
shift
echo "[$LEVEL] $*"
}

check_deps() {
log "INFO" "Checking required dependencies: $*"
export DEBIAN_FRONTEND=noninteractive

if ! dpkg -s "$@" > /dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt update..."
if [ ! -f /var/lib/apt/lists/lock ]; then
log "INFO" "Running apt update..."
apt update -y
fi
log "INFO" "Installing missing dependencies: $*"
apt -y install --no-install-recommends "$@"
else
log "INFO" "All required dependencies are already installed."
fi
}

export DEBIAN_FRONTEND=noninteractive
check_deps curl ca-certificates jq

check curl ca-certificates jq
get_version() {
VERSION="${VERSION:-latest}"

version() {
if [ "${VERSION}" = "latest" ]; then
if [ "$VERSION" = "latest" ]; then
log "INFO" "Fetching latest MongoDB Atlas CLI version from GitHub..."
URL="https://api.github.com/repos/mongodb/mongodb-atlas-cli/releases/latest"
if ! curl -sLf -o ./response.json "$URL"; then
echo "ERROR: Unable to fetch latest version"

if ! curl -sLf --fail -o ./response.json "$URL"; then
log "ERROR" "Unable to fetch latest version from GitHub API!"
exit 1
fi
export VERSION=$(cat ./response.json | jq -r '.tag_name | sub("atlascli/v"; "")')

VERSION=$(jq -r '.tag_name | sub("atlascli/v"; "")' < ./response.json)
log "INFO" "Latest version found: v$VERSION"
else
export VERSION=$(echo ${VERSION} | sed 's/v//')
VERSION=$(echo "$VERSION" | sed 's/v//')
log "INFO" "Using specified version: v$VERSION"
fi

export VERSION
}

download() {
detect_arch() {
log "INFO" "Detecting system architecture..."
ARCH="$(dpkg --print-architecture)"

case ${ARCH} in
amd64)
URL="https://github.com/mongodb/mongodb-atlas-cli/releases/download/atlascli%2Fv"${VERSION}"/mongodb-atlas-cli_"${VERSION}"_linux_x86_64.deb"
;;
arm64)
URL="https://github.com/mongodb/mongodb-atlas-cli/releases/download/atlascli%2Fv"${VERSION}"/mongodb-atlas-cli_"${VERSION}"_linux_arm64.deb"
;;
*) echo "(!) Architecture ${architecture} not supported."
exit 1
;;
case "$(uname -m)" in
x86_64 | amd64) ARCH="x86_64" ;;
aarch64 | arm64) ARCH="arm64" ;;
*) log "ERROR" "Unsupported architecture: $(uname -m)"; exit 1 ;;
esac

if ! curl -sLf -o ./mongodb-atlas-cli.deb "$URL"; then
echo "ERROR: Unable to download file"
log "INFO" "Architecture detected: $ARCH"
export ARCH
}

download_binary() {
if [ -z "$VERSION" ] || [ -z "$ARCH" ]; then
log "ERROR" "Missing version or architecture information!"
exit 1
fi

URL="https://github.com/mongodb/mongodb-atlas-cli/releases/download/atlascli%2Fv${VERSION}/mongodb-atlas-cli_${VERSION}_linux_${ARCH}.deb"

log "INFO" "Downloading MongoDB Atlas CLI from $URL"

if ! curl -sLf --fail -o ./mongodb-atlas-cli.deb "$URL"; then
log "ERROR" "Failed to download MongoDB Atlas CLI!"
exit 1
fi

log "INFO" "Download complete!"
}

install() {
chown root:root ./mongodb-atlas-cli.deb
apt install ./mongodb-atlas-cli.deb
install_binary() {
log "INFO" "Installing MongoDB Atlas CLI..."
apt install -y ./mongodb-atlas-cli.deb
log "INFO" "MongoDB Atlas CLI installed successfully!"
}

echo "Activating feature 'atlas'"
log "INFO" "Activating feature 'atlas'"

get_version
detect_arch
download_binary
install_binary

version
download
install
log "INFO" "Installation complete!"
4 changes: 2 additions & 2 deletions src/bicep/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "bicep",
"version": "1.0.3",
"version": "1.1.0",
"name": "Bicep CLI",
"description": "Command line tool (bicep)",
"documentationURL": "https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep",
Expand All @@ -21,4 +21,4 @@
"containerEnv": {
"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT": "1"
}
}
}
Loading