From a9c004640ecc42d0c9935597e1d3f712eaa33b5d Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Thu, 28 Apr 2016 10:55:46 -0700 Subject: [PATCH] build/push-official-release.sh checks if proper account is active, not just present --- build/common.sh | 4 ++-- build/push-official-release.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/common.sh b/build/common.sh index c83942e1e65..ca69acf7d7b 100755 --- a/build/common.sh +++ b/build/common.sh @@ -1516,9 +1516,9 @@ function kube::release::docker::release() { fi } -function kube::release::has_gcloud_account() { +function kube::release::gcloud_account_is_active() { local -r account="${1-}" - if [[ -n $(gcloud auth list --filter-account $account 2>/dev/null) ]]; then + if [[ -n $(gcloud auth list --filter-account $account 2>/dev/null | grep "active") ]]; then return 0 else return 1 diff --git a/build/push-official-release.sh b/build/push-official-release.sh index 5ef4ace5262..d73d4ab3a57 100755 --- a/build/push-official-release.sh +++ b/build/push-official-release.sh @@ -38,6 +38,7 @@ KUBE_GCS_PUBLISH_VERSION="${KUBE_RELEASE_VERSION}" KUBE_DOCKER_REGISTRY="gcr.io/google_containers" KUBE_DOCKER_IMAGE_TAG="${KUBE_RELEASE_VERSION}" +KUBE_GCLOUD_PRODUCTION_ACCOUNT="k8s.production.user@gmail.com" KUBE_ROOT="$(dirname "${BASH_SOURCE}")/.." source "${KUBE_ROOT}/build/common.sh" @@ -47,8 +48,8 @@ if "${KUBE_ROOT}/cluster/kubectl.sh" 'version' | grep 'Client' | grep 'dirty'; t exit 1 fi -if ! kube::release::has_gcloud_account k8s.production.user@gmail.com; then - kube::log::error "Pushing images to gcr.io/google_containers requires credentials for account k8s.production.user@gmail.com" +if ! kube::release::gcloud_account_is_active "${KUBE_GCLOUD_PRODUCTION_ACCOUNT}"; then + kube::log::error "Pushing images to gcr.io/google_containers requires being logged in as ${KUBE_GCLOUD_PRODUCTION_ACCOUNT}" return 1 fi