You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "volatilemolotov (via GitHub)" <gi...@apache.org> on 2023/05/26 09:43:05 UTC

[GitHub] [beam] volatilemolotov commented on a diff in pull request #26859: fix: get google apt key with gpg commmand

volatilemolotov commented on code in PR #26859:
URL: https://github.com/apache/beam/pull/26859#discussion_r1206507351


##########
playground/infrastructure/cloudbuild/cloudbuild_playground_infra.sh:
##########
@@ -40,16 +40,31 @@ apt-get -qq install -y google-cloud-sdk-gke-gcloud-auth-plugin google-cloud-sdk
 git clone --branch $BRANCH_NAME $REPO_NAME --single-branch
 cd beam
 mkdir playground/terraform/environment/$ENVIRONMENT_NAME
- 
-gcloud storage buckets create gs://$TF_VAR_state_bucket --location $TF_VAR_region --project $TF_VAR_project_id --pap
-if [ $? -eq 0 ]
-then 
-        echo "Creation successfull"
+
+
+checkBucket=$(curl -s -H "X-Goog-User-Project: $(gcloud config get-value project)" -H "Authorization: Bearer $(gcloud auth print-access-token)" https://storage.googleapis.com/storage/v1/b/$TF_VAR_state_bucket -w "%{http_code}" -o /dev/null)
+if [ $checkBucket -eq 200 ]; then
+        echo "Bucket already exists"
+elif [ $checkBucket -eq 404 ]; then
+        echo "Bucket does not exist, creating"
+        gcloud storage buckets create gs://$TF_VAR_state_bucket --location $TF_VAR_region --project $TF_VAR_project_id --pap
+                if [ $? -eq 0 ]
+                then 
+                        echo "Creation successfull"
+                else
+                        echo "Cannot create bucket, gcloud exit code: $?"
+                        exit 1
+                fi
+elif [ $checkBucket -eq 401 ]; then
+        echo "You do not have permission to access this bucket"
+        exit 1
 else
-        echo "Cannot create bucket, please check if the name is unique"
+        echo "Something went wrong, please check the bucket name"

Review Comment:
   Its part of the else wiring. Added a write of the error code, not sure what else to expect



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org