Skip to content

Commit 7fb5987

Browse files
committed
update deploy.sh
1 parent e529c1e commit 7fb5987

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

broker/cloud_functions/lsst/deploy.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,35 @@
22
# Deploys or deletes broker Cloud Functions
33
# This script will not delete Cloud Functions that are in production
44

5-
testid="${1:-test}"
65
# "False" uses production resources
76
# any other string will be appended to the names of all resources
8-
teardown="${2:-False}"
7+
testid="${1:-test}"
98
# "True" tearsdown/deletes resources, else setup
10-
survey="${3:-lsst}"
9+
teardown="${2:-False}"
1110
# name of the survey this broker instance will ingest
12-
versiontag="${4:-v3_3}"
11+
survey="${3:-lsst}"
12+
# schema version
13+
versiontag="${4:-v7_3}"
1314
region="${5:-us-central1}"
1415
PROJECT_ID=$GOOGLE_CLOUD_PROJECT # get the environment variable
1516

16-
#--- GCP resources used in this script
17-
avro_bucket="${PROJECT_ID}-${survey}_alerts_${versiontag}"
18-
avro_topic="projects/${PROJECT_ID}/topics/${survey}-alert_avros"
19-
ps_to_gcs_trigger_topic="${survey}-alerts_raw"
20-
ps_to_gcs_CF_name="${survey}-upload_bytes_to_bucket"
17+
# function used to define GCP resources; appends testid if needed
18+
define_GCP_resources() {
19+
local base_name="$1"
20+
local testid_suffix=""
2121

22-
# use test resources, if requested
23-
if [ "${testid}" != "False" ]; then
24-
avro_bucket="${avro_bucket}-${testid}"
25-
avro_topic="${avro_topic}-${testid}"
26-
ps_to_gcs_trigger_topic="${ps_to_gcs_trigger_topic}-${testid}"
27-
ps_to_gcs_CF_name="${ps_to_gcs_CF_name}-${testid}"
28-
fi
22+
if [ "$testid" != "False" ]; then
23+
testid_suffix="-${testid}"
24+
fi
25+
26+
echo "${base_name}${testid_suffix}"
27+
}
28+
29+
#--- GCP resources used in this script
30+
avro_bucket=$(define_GCP_resources "${PROJECT_ID}-${survey}_alerts_${versiontag}")
31+
avro_topic=$(define_GCP_resources "projects/${PROJECT_ID}/topics/${survey}-alert_avros")
32+
ps_to_gcs_trigger_topic=$(define_GCP_resources "${survey}-alerts_raw")
33+
ps_to_gcs_CF_name=$(define_GCP_resources "${survey}-upload_bytes_to_bucket")
2934

3035
if [ "${teardown}" = "True" ]; then
3136
# ensure that we do not teardown production resources

0 commit comments

Comments
 (0)