Skip to content

Commit

Permalink
Add check for storage existence before creation in cache client
Browse files Browse the repository at this point in the history
  • Loading branch information
octonawish-akcodes committed Jul 26, 2023
1 parent 528df29 commit 3f87ae8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cloud
Original file line number Diff line number Diff line change
Expand Up @@ -1257,16 +1257,24 @@ function pubsub_withdraw() {
function storage_deploy() {
declare -r project="$1"; shift
declare -r bucket="$1"; shift
TMPDIR="$TMPDIR_ORIG" gsutil -q mb -p "$project" -c STANDARD \
-l "us-central1" -b on "gs://$bucket"
# Check if the bucket exists
if ! gsutil ls "gs://$bucket" &>/dev/null; then
# Create the bucket if it doesn't exist
TMPDIR="$TMPDIR_ORIG" gsutil -q mb -p "$project" -c STANDARD \
-l "us-central1" -b on "gs://$bucket"
fi
TMPDIR="$TMPDIR_ORIG" gsutil iam ch allUsers:objectViewer "gs://$bucket/"
}

# Remove a Google Cloud Storage Bucket and its contents
# Args: bucket
function storage_withdraw() {
declare -r bucket="$1"; shift
TMPDIR="$TMPDIR_ORIG" gsutil -q -m rm -r "gs://$bucket"
# Check if the bucket exists
if gsutil ls "gs://$bucket" &>/dev/null; then
# Remove the bucket and its contents if it exists
TMPDIR="$TMPDIR_ORIG" gsutil -q -m rm -r "gs://$bucket"
fi
}

# Deploy a Cloud Function
Expand Down

0 comments on commit 3f87ae8

Please sign in to comment.