Skip to content

Commit 0b51b7d

Browse files
committed
fix(catalog): add gcloud_installer.sh for Google Cloud CLI
The install_method must match an existing installer script. Create gcloud_installer.sh following the aws_installer.sh pattern: fresh installs via sdk.cloud.google.com, updates via gcloud components update. Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de> Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
1 parent 1bc941b commit 0b51b7d

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

catalog/gcloud.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gcloud",
33
"category": "platform",
4-
"install_method": "manual",
4+
"install_method": "gcloud_installer",
55
"description": "Google Cloud CLI for managing Google Cloud resources",
66
"homepage": "https://cloud.google.com/sdk/gcloud",
77
"binary_name": "gcloud",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
# Google Cloud CLI installer
3+
set -euo pipefail
4+
5+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
. "$DIR/lib/install_strategy.sh"
7+
8+
TOOL="${1:-gcloud}"
9+
CATALOG_FILE="$DIR/../catalog/$TOOL.json"
10+
11+
if [ ! -f "$CATALOG_FILE" ]; then
12+
echo "Error: Catalog file not found: $CATALOG_FILE" >&2
13+
exit 1
14+
fi
15+
16+
BINARY_NAME="$(jq -r '.binary_name' "$CATALOG_FILE")"
17+
18+
# Get current version
19+
before="$(command -v "$BINARY_NAME" >/dev/null 2>&1 && "$BINARY_NAME" version 2>/dev/null | head -1 || true)"
20+
21+
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
22+
# Already installed - use built-in update
23+
"$BINARY_NAME" components update --quiet 2>&1 || true
24+
else
25+
# Fresh install via Google Cloud SDK installer
26+
TMP="$(mktemp -d)"
27+
cd "$TMP"
28+
curl -fsSL https://sdk.cloud.google.com -o install.sh
29+
bash install.sh --disable-prompts --install-dir="$HOME" 2>&1
30+
cd - >/dev/null
31+
rm -rf "$TMP"
32+
33+
# Add to PATH if not already present
34+
GCLOUD_BIN="$HOME/google-cloud-sdk/bin"
35+
if [ -d "$GCLOUD_BIN" ] && ! command -v "$BINARY_NAME" >/dev/null 2>&1; then
36+
export PATH="$GCLOUD_BIN:$PATH"
37+
fi
38+
fi
39+
40+
# Report
41+
after="$(command -v "$BINARY_NAME" >/dev/null 2>&1 && "$BINARY_NAME" version 2>/dev/null | head -1 || true)"
42+
path="$(command -v "$BINARY_NAME" 2>/dev/null || true)"
43+
printf "[%s] before: %s\n" "$TOOL" "${before:-<none>}"
44+
printf "[%s] after: %s\n" "$TOOL" "${after:-<none>}"
45+
if [ -n "$path" ]; then printf "[%s] path: %s\n" "$TOOL" "$path"; fi
46+
47+
# Refresh snapshot after successful installation
48+
refresh_snapshot "$TOOL"

0 commit comments

Comments
 (0)