Skip to content

Commit

Permalink
cloud: Add storage_bucket to cloud functions env
Browse files Browse the repository at this point in the history
  • Loading branch information
octonawish-akcodes committed Jul 25, 2023
1 parent 528df29 commit 675e517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions cloud
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ function cloud_functions_env() {
smtp_to_addrs smtp_password_secret \
smtp_topic smtp_subscription \
pgpass_secret \
cache_bucket_name \
database \
clean_test_databases \
empty_test_databases \
Expand Down Expand Up @@ -1353,6 +1354,9 @@ function cloud_functions_env() {
if [ -n "$extra_cc" ]; then
env[KCIDB_EXTRA_CC]="$extra_cc"
fi
if [ -n "$cache_bucket_name" ]; then
env[KCIDB_CACHE_BUCKET_NAME]="$cache_bucket_name"
fi
if [ -n "$smtp_to_addrs" ]; then
env[KCIDB_SMTP_TO_ADDRS]="$smtp_to_addrs"
fi
Expand Down Expand Up @@ -1764,7 +1768,7 @@ function execute_command() {
eval "declare -a argv=($argv)"

declare -r load_queue_trigger_topic="${prefix}load_queue_trigger"
declare -r storage_bucket="${project}_${prefix}cache"
declare -r cache_bucket_name="${project}_${prefix}cache"
declare -r pick_notifications_trigger_topic="${prefix}pick_notifications_trigger"
declare -r updated_urls_topic="${prefix}updated_urls"
declare -r new_topic="${prefix}new"
Expand Down Expand Up @@ -1891,6 +1895,7 @@ function execute_command() {

declare -r -a env_args=(
--log-level="$log_level"
--cache-bucket-name="$cache_bucket_name"
--optimize="$optimize"
--heavy-asserts="$heavy_asserts"
--new-topic="$new_topic"
Expand Down Expand Up @@ -1953,7 +1958,7 @@ function execute_command() {
--smtp-topic="$smtp_topic" \
--smtp-subscription="$smtp_subscription"
sections_run "$sections" firestore_deploy "$project"
sections_run "$sections" storage_deploy "$project" "$storage_bucket"
sections_run "$sections" storage_deploy "$project" "$cache_bucket_name"
sections_run "$sections" cloud_functions_deploy \
--project="$project" \
--prefix="$prefix" \
Expand Down Expand Up @@ -1985,7 +1990,7 @@ function execute_command() {
"$project" "$new_topic" "${submitters[@]}"
sections_run "$sections" scheduler_withdraw "$project" "$prefix"
sections_run "$sections" cloud_functions_withdraw "$project" "$prefix"
sections_run "$sections" storage_withdraw "$storage_bucket"
sections_run "$sections" storage_withdraw "$cache_bucket_name"
sections_run "$sections" firestore_withdraw \
"$project" "$spool_collection_path"
sections_run "$sections" pubsub_withdraw \
Expand Down Expand Up @@ -2267,7 +2272,7 @@ function execute() {
fi
if [[ $command == @(deploy|env|shell) ]]; then
getopt_longopts+=",extra-cc:,smtp-to-addrs:"
getopt_longopts+=",log-level:,optimize:,heavy-asserts,mute-updates"
getopt_longopts+=",log-level:,optimize:,cache-bucket-name:,heavy-asserts,mute-updates"
if [[ $command == env ]]; then
getopt_longopts+=",format:"
fi
Expand Down Expand Up @@ -2299,6 +2304,7 @@ function execute() {
declare test="false"
declare log_level="INFO"
declare optimize=""
declare cache_bucket_name=""
declare heavy_asserts="false"
declare updated_publish="true"
declare -a submitters=()
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
# The publisher object for the queue with patterns matching objects updated by
# loading submissions.
_UPDATED_QUEUE_PUBLISHER = None
# KCIDB cache storage bucket name
CACHE_BUCKET_NAME = os.environ.get("KCIDB_CACHE_BUCKET_NAME")


def get_smtp_publisher():
Expand Down Expand Up @@ -356,7 +358,7 @@ def get_cache_client():
global _CACHE_CLIENT
if _CACHE_CLIENT is None:
_CACHE_CLIENT = kcidb.cache.Client(
"cache_file_storage", 5 * 1024 * 1024
CACHE_BUCKET_NAME, 5 * 1024 * 1024
)
return _CACHE_CLIENT

Expand Down

0 comments on commit 675e517

Please sign in to comment.