From c94f77832ff04e1e844e350397edf0941b8e5792 Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Wed, 2 Jun 2021 16:34:07 +0100 Subject: [PATCH] updated gcp_cli_create_credential.sh --- gcp_cli_create_credential.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcp_cli_create_credential.sh b/gcp_cli_create_credential.sh index 7a8ce44e..1906c267 100755 --- a/gcp_cli_create_credential.sh +++ b/gcp_cli_create_credential.sh @@ -34,7 +34,7 @@ The following optional arguments can be given: - service account name prefix (default: \$USER-cli) - credential file path (default: \$HOME/.gcloud/\$name-\$project-credential.json) -- project (default: gcloud config's currently configured project setting core.project) +- project (default: \$CLOUDSDK_CORE_PROJECT or gcloud config's currently configured project setting core.project) This can also be used as a backup credential - this way if something accidentally happens to your primary user account or this service account, you can always use the other to repair access without having to rely on colleagues who be away @@ -52,9 +52,9 @@ help_usage "$@" name="${1:-$USER-cli}" -project="${3:-$(gcloud config list --format='get(core.project)')}" +project="${3:-${CLOUDSDK_CORE_PROJECT:-$(gcloud config list --format='get(core.project)')}}" -# XXX: fix the GCP project for the duration of the script for consistency +# XXX: sets the GCP project for the duration of the script for consistency purposes (relying on gcloud config could lead to race conditions) not_blank "$project" || die "ERROR: no project specified and GCloud SDK core.project value not set" export CLOUDSDK_CORE_PROJECT="$project"