Merge pull request #30008 from fejta/gke

Use format instead of awk to extract active account/project
This commit is contained in:
Daniel Smith 2016-08-03 12:58:12 -07:00 committed by GitHub
commit 8f4f682659

View File

@ -1086,7 +1086,7 @@ function kube::release::gcs::verify_prereqs() {
fi
if [[ -z "${GCLOUD_ACCOUNT-}" ]]; then
GCLOUD_ACCOUNT=$(gcloud auth list 2>/dev/null | awk '/(active)/ { print $2 }')
GCLOUD_ACCOUNT=$(gcloud config list --format='value(core.account)' 2>/dev/null)
fi
if [[ -z "${GCLOUD_ACCOUNT-}" ]]; then
echo "No account authorized through gcloud. Please fix with:"
@ -1096,7 +1096,7 @@ function kube::release::gcs::verify_prereqs() {
fi
if [[ -z "${GCLOUD_PROJECT-}" ]]; then
GCLOUD_PROJECT=$(gcloud config list project | awk '{project = $3} END {print project}')
GCLOUD_PROJECT=$(gcloud config list --format='value(core.project)' 2>/dev/null)
fi
if [[ -z "${GCLOUD_PROJECT-}" ]]; then
echo "No account authorized through gcloud. Please fix with:"
@ -1594,7 +1594,7 @@ function kube::release::docker::release() {
function kube::release::gcloud_account_is_active() {
local -r account="${1-}"
if [[ -n $(gcloud auth list --filter-account $account 2>/dev/null | grep "active") ]]; then
if [[ "$(gcloud config list --format='value(core.account)')" == "${account}" ]]; then
return 0
else
return 1