32 lines
970 B
Bash
32 lines
970 B
Bash
#!/bin/bash
|
|
|
|
# Simple script to provision AIRFLOW_CONNECTIONS !
|
|
|
|
export SQLALCHEMY_SILENCE_UBER_WARNING=1
|
|
#export AIRFLOW_CONN_AIRFLOW_DB="${connection}"
|
|
export AIRFLOW__DATABASE__SQL_ALCHEMY_CONN="${connection}"
|
|
export AIRFLOW__CORE__SQL_ALCHEMY_CONN="${connection}"
|
|
|
|
echo "====================================="
|
|
conns=$(compgen -v -X '!*AIRFLOW_CONN_*')
|
|
|
|
if [ -z "${conns}" ];then
|
|
echo " Nothing to do"
|
|
echo "====================================="
|
|
else
|
|
for conn in ${conns}
|
|
do
|
|
name="${conn#"AIRFLOW_CONN_"}"
|
|
value=$(eval "echo -e ${!conn}")
|
|
echo "Creating ${name}: ${value}"
|
|
ex=$(airflow connections add "${name}" --conn-uri ${value} 2>&1)
|
|
if [ "${?}" -ne 0 ]; then
|
|
echo "${conn}: Bad connection definition"
|
|
echo "= Error =========================="
|
|
echo "${ex}"
|
|
echo "= End error======================="
|
|
else
|
|
echo "= Ok ================================"
|
|
fi
|
|
done
|
|
fi |