Skip to content

Commit

Permalink
Use format instead of awk to extract active account/project
Browse files Browse the repository at this point in the history
  • Loading branch information
fejta committed Aug 3, 2016
1 parent 804109d commit add6feb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand All @@ -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:"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit add6feb

Please sign in to comment.