Skip to content
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
29 changes: 29 additions & 0 deletions features/src/gcloud/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Google Cloud CLI (gcloud)

Installs [Google Cloud CLI](https://cloud.google.com/sdk/gcloud) via the official tarball.

## Usage

```json
"features": {
"ghcr.io/shokkunrf/devcontainer-features/gcloud": {}
}
```

## Requirements

- `curl` and `tar` must be available in the container
- Linux (x86_64 or aarch64)
- aarch64: Python 3.9-3.14 must be installed (x86_64 bundles Python)

## Using host credentials

To forward your host's gcloud credentials into the container, add the following to `devcontainer.json`:

```json
"mounts": [
"source=${localEnv:HOME}/.config/gcloud,target=/home/vscode/.config/gcloud,type=bind,consistency=cached"
]
```

Replace `/home/vscode` with the appropriate home directory for your container user.
12 changes: 12 additions & 0 deletions features/src/gcloud/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"id": "gcloud",
"version": "1.0.0",
"name": "Google Cloud CLI",
"documentationURL": "https://github.com/shokkunrf/devcontainer/tree/develop/features/src/gcloud/README.md",
"description": "Installs Google Cloud CLI via the official tarball",
"options": {},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/python"
]
}
28 changes: 28 additions & 0 deletions features/src/gcloud/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
# References:
# - https://cloud.google.com/sdk/docs/install-sdk

set -eu

echo "Activating feature 'gcloud'"

# Determine architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH_SUFFIX="x86_64" ;;
aarch64) ARCH_SUFFIX="arm" ;;
*)
echo "ERROR: Unsupported architecture: $ARCH"
exit 1
;;
esac

INSTALL_DIR="/usr/local"
TARBALL="google-cloud-cli-linux-${ARCH_SUFFIX}.tar.gz"
curl -fsSL "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/${TARBALL}" | tar -xz -C "$INSTALL_DIR"

"${INSTALL_DIR}/google-cloud-sdk/install.sh" --quiet --path-update false --command-completion false

ln -s "${INSTALL_DIR}/google-cloud-sdk/bin/gcloud" /usr/local/bin/gcloud

echo "Google Cloud CLI installed successfully!"
1 change: 1 addition & 0 deletions features/test/gcloud/devcontainer-base-debian.sh
1 change: 1 addition & 0 deletions features/test/gcloud/devcontainer-base-ubuntu-root.sh
1 change: 1 addition & 0 deletions features/test/gcloud/official-debian.sh
29 changes: 29 additions & 0 deletions features/test/gcloud/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"official-debian": {
"image": "debian:trixie",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"gcloud": {}
}
},
"devcontainer-base-debian": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"gcloud": {}
},
"remoteUser": "vscode"
},
"devcontainer-base-ubuntu-root": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"gcloud": {}
}
},
"devcontainer-base-ubuntu-remote-user": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"gcloud": {}
},
"remoteUser": "vscode"
}
}
13 changes: 13 additions & 0 deletions features/test/gcloud/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# Definition specific tests
check "gcloud is installed" gcloud --version
check "gcloud is upgradable" gcloud components update --quiet

# Report result
reportResults
Loading