Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Make Airflow connection variables easier to read (#480)
rwidome98cf7993b5e
diff --git a/docker/airflow/entrypoint.sh b/docker/airflow/entrypoint.shindex 5db865626..0bf41f3ec 100755--- a/docker/airflow/entrypoint.sh+++ b/docker/airflow/entrypoint.sh@@ -34,6 +34,30 @@ function header() {if [ "$1" == help ] || [ "$1" == --help ]; then help_text && exit 0; fisleep 0.1; # The $COLUMNS variable takes a moment to populate+# Reformat Airflow connections that use https+header "MODIFYING ENVIRONMENT"+# Loop through environment variables, relying on naming conventions.+# Bash loops with pipes occur in a subprocess, so we need to do some special+# subprocess manipulation via <(...) syntax to allow the `export` calls+# to propagate to the outer shell.+# See: https://unix.stackexchange.com/a/402752+while read var_string; do+ # get the variable name+ var_name=`expr "$var_string" : '^\([A-Z_]*\)'`+ echo "Variable Name: $var_name"+ # get the old value+ old_value=`expr "$var_string" : '^[A-Z_]*=\(http.*\)$'`+ echo " Old Value: $old_value"+ # call python to url encode the http clause+ url_encoded=`python -c "from urllib.parse import quote_plus; import sys; print(quote_plus(sys.argv[1]))" $old_value`+ # prepend https://+ new_value='https://'$url_encoded+ echo " New Value: $new_value"+ # set the environment variable+ export $var_name=$new_value+# only include airflow connections with http somewhere in the string+done < <(env | grep "^AIRFLOW_CONN[A-Z_]\+=http.*$")+# Wait for postgresheader "WAITING FOR POSTGRES"python /opt/airflow/wait_for_db.pydiff --git a/env.template b/env.templateindex b34f1f092..bb6cd5f45 100644--- a/env.template+++ b/env.template@@ -46,8 +46,7 @@ AIRFLOW_CONN_AWS_DEFAULT=aws://test_key:test_secret@?region_name=us-east-1&host=# Change the following line in prod to use the appropriate DBAIRFLOW_CONN_POSTGRES_OPENLEDGER_UPSTREAM=postgres://deploy:deploy@postgres:5432/openledgerAIRFLOW_CONN_POSTGRES_OPENLEDGER_TESTING=postgres://deploy:deploy@postgres:5432/openledger-# Slack webhook connection info (this must be URL encoded, with a-# pre-pended https://, e.g. "https://https%3A%2F%2Fhooks.slack.com%2Fservices%2everythingelse")+# Slack webhook connection info (note that these values are modified by the Docker entrypoint)# A distinction is made here between "notifications" and "alerts", the former being# useful updates and the latter being alarms or actionable errors.AIRFLOW_CONN_SLACK_NOTIFICATIONS=https://slack@@ -65,8 +64,7 @@ AIRFLOW_CONN_EMR_TEST=emr://?host=http://s3:5000EMR_CONN_ID=emr_emptyEMR_TEST_CONN_ID=emr_test-# Connection to the Ingestion Server, used for managing data refreshes. (This must be URL encoded,-# with a pre-pended https://, e.g. "https://https%3A%2F%2Fhost.docker.internal%3A8001"))+# Connection to the Ingestion Server, used for managing data refreshes.AIRFLOW_CONN_DATA_REFRESH=not_set