Skip to content

Commit

Permalink
Auto-install gcloud if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Mar 31, 2015
1 parent 9ed8761 commit 98cdf04
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
8 changes: 6 additions & 2 deletions cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ function verify-prereqs {
local cmd
for cmd in gcloud gsutil; do
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
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
curl https://sdk.cloud.google.com | bash
fi
Expand Down
30 changes: 24 additions & 6 deletions cluster/gke/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Use the config file specified in $KUBE_CONFIG_FILE, or default to
# config-default.sh.

KUBE_PROMPT_FOR_UPDATE=y
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/gke/${KUBE_CONFIG_FILE:-config-default.sh}"

Expand Down Expand Up @@ -68,12 +69,29 @@ function test-build-release() {

# Verify needed binaries exist.
function verify-prereqs() {
echo "... in verify-prereqs()" >&2

${GCLOUD} preview --help >/dev/null || {
echo "Either the GCLOUD environment variable is wrong, or the 'preview' component"
echo "is not installed. (Fix with 'gcloud components update preview')"
}
if ! which gcloud >/dev/null; then
local resp
if [[ "${KUBE_PROMPT_FOR_UPDATE" == "y" ]]; then
echo "Can't find gcloud 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
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
Expand Down

0 comments on commit 98cdf04

Please sign in to comment.