Auto-install gcloud if needed.

pull/6/head
Brendan Burns 2015-03-30 10:20:29 -07:00
parent 9ed87612d0
commit 98cdf04189
2 changed files with 30 additions and 8 deletions

View File

@ -31,9 +31,13 @@ function verify-prereqs {
local cmd local cmd
for cmd in gcloud gsutil; do for cmd in gcloud gsutil; do
if ! which "${cmd}" >/dev/null; then if ! which "${cmd}" >/dev/null; then
echo "Can't find ${cmd} in PATH. Do you wish to install the Google Cloud SDK? [Y/n]"
local resp local resp
read resp if [[ "${KUBE_PROMPT_FOR_UPDATE" == "y" ]]; then
echo "Can't find ${cmd} in PATH. Do you wish to install the Google Cloud SDK? [Y/n]"
read resp
else
resp="y"
fi
if [[ "${resp}" != "n" && "${resp}" != "N" ]]; then if [[ "${resp}" != "n" && "${resp}" != "N" ]]; then
curl https://sdk.cloud.google.com | bash curl https://sdk.cloud.google.com | bash
fi fi

View File

@ -19,6 +19,7 @@
# Use the config file specified in $KUBE_CONFIG_FILE, or default to # Use the config file specified in $KUBE_CONFIG_FILE, or default to
# config-default.sh. # config-default.sh.
KUBE_PROMPT_FOR_UPDATE=y
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/gke/${KUBE_CONFIG_FILE:-config-default.sh}" source "${KUBE_ROOT}/cluster/gke/${KUBE_CONFIG_FILE:-config-default.sh}"
@ -68,12 +69,29 @@ function test-build-release() {
# Verify needed binaries exist. # Verify needed binaries exist.
function verify-prereqs() { function verify-prereqs() {
echo "... in verify-prereqs()" >&2 if ! which gcloud >/dev/null; then
local resp
${GCLOUD} preview --help >/dev/null || { if [[ "${KUBE_PROMPT_FOR_UPDATE" == "y" ]]; then
echo "Either the GCLOUD environment variable is wrong, or the 'preview' component" echo "Can't find gcloud in PATH. Do you wish to install the Google Cloud SDK? [Y/n]"
echo "is not installed. (Fix with 'gcloud components update preview')" read resp
} else
resp="y"
fi
if [[ "${resp}" != "n" && "${resp}" != "N" ]]; then
curl https://sdk.cloud.google.com | bash
fi
if ! which gcloud >/dev/null; then
echo "Can't find gcloud in PATH, please fix and retry. The Google Cloud "
echo "SDK can be downloaded from https://cloud.google.com/sdk/."
exit 1
fi
fi
# update and install components as needed
if [[ "${KUBE_PROMPT_FOR_UPDATE}" != "y" ]]; then
gcloud_prompt="-q"
fi
gcloud ${gcloud_prompt:-} components update preview || true
gcloud ${gcloud_prompt:-} components update || true
} }
# Instantiate a kubernetes cluster # Instantiate a kubernetes cluster