Created
May 27, 2020 03:08
-
-
Save erkolson/b75dbf48441d82409b79e91bc64b84be to your computer and use it in GitHub Desktop.
gcloud shell access shortcuts
This file contains hidden or 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
gcloudctx() { | |
context=$1 | |
if [ -z "$context" ] ; then | |
echo "USAGE: gcloudctx <context-name>" | |
echo "Available contexts:" | |
gcloud config configurations list | |
elif gcloud config configurations list --format="value(Name)" | grep "^$context$" &>/dev/null; then | |
gcloud config configurations activate $context | |
else | |
echo "Creating context $context" | |
gcloud config configurations create $context | |
fi | |
} | |
# Troubleshoot access token | |
gcloud_app_default() { | |
TOKEN=$(gcloud auth application-default print-access-token) | |
curl "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=${TOKEN}" | |
} | |
gcloud_access_token(){ | |
TOKEN=$(gcloud auth print-access-token) | |
curl "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=${TOKEN}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment