generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Google Cloud CLI feature and tests (#6)
- Loading branch information
Showing
7 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# google-cloud-cli | ||
|
||
Install the [Google Cloud CLI](https://cloud.google.com/cli). | ||
|
||
## Usage | ||
|
||
```json | ||
"features": { | ||
"ghcr.io/CargoSense/devcontainer-features/google-cloud-cli:1": {} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
| Option ID | Description | Type | Default Value | | ||
|:----------|:-----------------------------------------|:-------|:--------------| | ||
| `version` | The google-cloud-cli version to install. | string | `latest` | | ||
|
||
## OS Support | ||
|
||
This Feature should work on recent versions of Debian/Ubuntu and Linux distributions using the [apt](https://wiki.debian.org/AptCLI) management tool. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Google Cloud CLI", | ||
"id": "google-cloud-cli", | ||
"version": "1.1.0", | ||
"description": "Install Google Cloud CLI, a tool for creating and managing Google Cloud resources and services.", | ||
"options": { | ||
"version": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest" | ||
], | ||
"default": "latest", | ||
"description": "Select or enter a Google Cloud CLI version." | ||
} | ||
}, | ||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
GOOGLE_CLOUD_CLI_VERSION="${VERSION:-"latest"}" | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
printf 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
curl_installed="" | ||
gpg_installed="" | ||
|
||
if ! type curl >/dev/null 2>&1; then | ||
apt-get update --yes | ||
apt-get install --no-install-recommends --yes curl ca-certificates | ||
|
||
curl_installed="true" | ||
fi | ||
|
||
if ! type gpg >/dev/null 2>&1; then | ||
apt-get update --yes | ||
apt-get install --no-install-recommends --yes gpg | ||
|
||
gpg_installed="true" | ||
fi | ||
|
||
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg | ||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | ||
|
||
apt-get update --yes | ||
|
||
if [ "${GOOGLE_CLOUD_CLI_VERSION}" = "latest" ]; then | ||
apt-get install --no-install-recommends --yes postgresql-client | ||
else | ||
apt-get install --no-install-recommends --yes google-cloud-cli="${GOOGLE_CLOUD_CLI_VERSION}" | ||
fi | ||
|
||
if [ -n "${curl_installed}" ]; then | ||
apt purge curl --autoremove --yes | ||
fi | ||
|
||
if [ -n "${gpg_installed}" ]; then | ||
apt purge gpg --autoremove --yes | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
check "version" bash -c "gcloud --version | grep 1.6.20" | ||
check "which gcloud" bash -c "which gcloud | grep /usr/bin/gcloud" | ||
|
||
# Report result | ||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
check "version" gcloud --version | ||
check "which gcloud" bash -c "which gcloud | grep /usr/bin/gcloud" | ||
|
||
# Report result | ||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"install-bookworm": { | ||
"image": "debian:bookworm", | ||
"features": { | ||
"google-cloud-cli": { | ||
"version": "latest" | ||
} | ||
} | ||
}, | ||
|
||
"install-bookworm-with-settings": { | ||
"image": "debian:bookworm", | ||
"features": { | ||
"google-cloud-cli": { | ||
"version": "371.0.0-0" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
check "version" gcloud --version | ||
check "which gcloud" bash -c "which gcloud | grep /usr/bin/gcloud" | ||
|
||
# Report result | ||
reportResults |