Use format instead of awk to extract active account/project

This commit is contained in:
Erick Fejta 2016-08-03 10:46:20 -07:00
parent 804109d349
commit add6feb53c

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