Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize the env file used to run the custom dc dev script. #4819

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .run_cdc_dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

# Env variables for running run_cdc_dev.sh

# The 3 keys / passwords below are not checked in.
# Either uncomment these lines and set them here or set them separately as environment variables.
# DC_API_KEY=
# MAPS_API_KEY=
# DB_PASS=
# The 3 keys / passwords below must be specified before the script can be run.
# Either specify them here or better still is to
# copy this file, specify the values in the copy and set the env variable RUN_CDC_DEV_ENV_FILE to that file's path before running the script.
# e.g. if the copied file is at tmp/cdc.env, you can run the script as follows:
# RUN_CDC_DEV_ENV_FILE=tmp/cdc.env ./run_cdc_dev.sh
DC_API_KEY=
MAPS_API_KEY=
DB_PASS=

# If your DC_API_KEY is for autopush, change this to https://autopush.api.datacommons.org
DC_API_ROOT=https://api.datacommons.org
Expand Down
6 changes: 4 additions & 2 deletions run_cdc_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ set -e
# Kill forked processes on exit.
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

source .run_cdc_dev.env && export $(sed '/^#/d' .run_cdc_dev.env | cut -d= -f1)
ENV_FILE=${RUN_CDC_DEV_ENV_FILE:-.run_cdc_dev.env}
echo "Using environment file: $ENV_FILE"
source $ENV_FILE && export $(sed '/^#/d' $ENV_FILE | cut -d= -f1)

# Print commit hashes.
echo -e "\033[0;32m" # Set different color.
Expand Down Expand Up @@ -60,7 +62,7 @@ fi

# Validate api root and key by making an API call.
echo
url="${DC_API_ROOT}/v2/node?key=${DC_API_KEY}&nodes=geoId/06&property=<-"
url="${DC_API_ROOT}/v2/node?key=${DC_API_KEY}&nodes=geoId/06&property=%3C-"
echo "Calling API to validate key: $url"
# Perform the request and capture both output and HTTP status code
response=$(curl --silent --output /dev/null --write-out "%{http_code}" "$url")
Expand Down
Loading