Created
May 8, 2020 11:42
-
-
Save palnabarun/dcfc6f0259cc4e0e03926f92c5d637a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch_gcp () { | |
if [ -z $1 ] | |
then | |
echo "No profile name passed." | |
exit 1 | |
fi | |
GCP_CRED_HOME=$HOME/.gcloud_credentials | |
GCP_CRED_FILE=$GCP_CRED_HOME/$1.json | |
if [ ! -f $GCP_CRED_FILE ] | |
then | |
echo "Profile " $1 "not found." | |
exit 1 | |
fi | |
if ! gcloud config configurations describe $1 | |
then | |
echo "Profie " $1 "not configured in gcloud." | |
exit 1 | |
fi | |
export GOOGLE_CREDENTIALS=$GCP_CRED_FILE | |
gcloud config configurations activate $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment