-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# KCIDB cloud deployment - storage | ||
# | ||
if [ -z "${_STORAGE_SH+set}" ]; then | ||
declare _STORAGE_SH= | ||
|
||
. misc.sh | ||
|
||
# Deploy a Google Cloud Storage Bucket | ||
# Args: project bucket | ||
function storage_deploy() { | ||
declare -r project="$1"; shift | ||
declare -r bucket="$1"; shift | ||
# Check if the bucket exists | ||
if ! TMPDIR="$TMPDIR_ORIG" 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 -q 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 | ||
# Check if the bucket exists | ||
if TMPDIR="$TMPDIR_ORIG" 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 | ||
} | ||
|
||
fi # _STORAGE_SH |