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

Added option to install PubSub emulator #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/google-cloud-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"type": "boolean",
"default": false,
"description": "Install 'gke-gcloud-auth-plugin' plugin?"
},
"installPubSubEmulator": {
"type": "boolean",
"default": false,
"description": "Install the 'google-cloud-cli-pubsub-emulator'?"
}
},
"installsAfter": [
Expand Down
9 changes: 8 additions & 1 deletion src/google-cloud-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set -e
rm -rf /var/lib/apt/lists/*

GCLOUD_VERSION=${VERSION:-"latest"}
INSTALL_GKEGCLOUDAUTH_PLUGIN="${INSTALL_GKEGCLOUDAUTH_PLUGIN:-"false"}"
INSTALL_GKEGCLOUDAUTH_PLUGIN="${INSTALLGKEGCLOUDAUTHPLUGIN:-"false"}"
INSTALL_PUBSUB_EMULATOR="${INSTALLPUBSUBEMULATOR:-"false"}"

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
Expand Down Expand Up @@ -94,6 +95,12 @@ install_using_apt() {
echo "(*) Installing 'gke-gcloud-auth-plugin' plugin..."
check_packages google-cloud-sdk-gke-gcloud-auth-plugin
fi

# Install pubsub emulator if needed
if [ "${INSTALL_PUBSUB_EMULATOR}" = "true" ]; then
echo "(*) Installing 'pubsub-emulator' plugin..."
check_packages google-cloud-cli-pubsub-emulator
fi
}

echo "(*) Installing google-cloud CLI..."
Expand Down
11 changes: 11 additions & 0 deletions test/google-cloud-cli/install_gke_auth_plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

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

check "gke-gcloud-auth-plugin is installed" grep "gke-gcloud-auth-plugin" <(gcloud --version)

# Report result
reportResults
11 changes: 11 additions & 0 deletions test/google-cloud-cli/install_pubsub_emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

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

check "pubsub-emulator is installed" grep "pubsub-emulator" <(gcloud --version)

# Report result
reportResults
11 changes: 11 additions & 0 deletions test/google-cloud-cli/install_specific_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

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

check "gcloud version 430.0.0 installed" grep "430.0.0" <(gcloud --version)

# Report result
reportResults
26 changes: 26 additions & 0 deletions test/google-cloud-cli/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"install_specific_version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"google-cloud-cli": {
"version": "430.0.0"
}
}
},
"install_gke_auth_plugin": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"google-cloud-cli": {
"installGkeGcloudAuthPlugin": true
}
}
},
"install_pubsub_emulator": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"google-cloud-cli": {
"installPubsubEmulator": true
}
}
}
}
2 changes: 2 additions & 0 deletions test/google-cloud-cli/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ source dev-container-features-test-lib
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "gcloud version" gcloud --version
check "gke-gcloud-auth-plugin is not installed" [ "$(grep "gke-gcloud-auth-plugin" <(gcloud --version))" = "" ]
check "pubsub-emulator is not installed" [ "$(grep "pubsub-emulator" <(gcloud --version))" = "" ]

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
Expand Down