|
2 | 2 | # Deploys or deletes broker Cloud Functions |
3 | 3 | # This script will not delete Cloud Functions that are in production |
4 | 4 |
|
5 | | -testid="${1:-test}" |
6 | 5 | # "False" uses production resources |
7 | 6 | # any other string will be appended to the names of all resources |
8 | | -teardown="${2:-False}" |
| 7 | +testid="${1:-test}" |
9 | 8 | # "True" tearsdown/deletes resources, else setup |
10 | | -survey="${3:-lsst}" |
| 9 | +teardown="${2:-False}" |
11 | 10 | # 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}" |
13 | 14 | region="${5:-us-central1}" |
14 | 15 | PROJECT_ID=$GOOGLE_CLOUD_PROJECT # get the environment variable |
15 | 16 |
|
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="" |
21 | 21 |
|
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") |
29 | 34 |
|
30 | 35 | if [ "${teardown}" = "True" ]; then |
31 | 36 | # ensure that we do not teardown production resources |
|
0 commit comments