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

updates from Leo #61

Merged
merged 4 commits into from
Jan 6, 2024
Merged
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
55 changes: 32 additions & 23 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,44 @@ set -o pipefail
echo "dbt project folder set as: \"${INPUT_DBT_PROJECT_FOLDER}\""
cd ${INPUT_DBT_PROJECT_FOLDER}

if [ -n "${DBT_BIGQUERY_TOKEN}" ]
export PROFILES_FILE="${DBT_PROFILES_DIR:-.}/profiles.yml"
if [ -e "${PROFILES_FILE}" ] # check if file exist
then
echo trying to parse bigquery token
$(echo ${DBT_BIGQUERY_TOKEN} | base64 -d > ./creds.json 2>/dev/null)
if [ $? -eq 0 ]
if [ -n "${DBT_BIGQUERY_TOKEN}" ]
then
echo success parsing base64 encoded token
elif $(echo ${DBT_BIGQUERY_TOKEN} > ./creds.json)
echo trying to parse bigquery token
$(echo ${DBT_BIGQUERY_TOKEN} | base64 -d > ./creds.json 2>/dev/null)
if [ $? -eq 0 ]
then
echo success parsing base64 encoded token
elif $(echo ${DBT_BIGQUERY_TOKEN} > ./creds.json)
then
echo success parsing plain token
else
echo cannot parse bigquery token
exit 1
fi
elif [ -n "${DBT_USER}" ] && [ -n "$DBT_PASSWORD" ]
then
echo success parsing plain token
echo trying to use user/password
sed -i "s/_user_/${DBT_USER}/g" $PROFILES_FILE
sed -i "s/_password_/${DBT_PASSWORD}/g" $PROFILES_FILE
elif [ -n "${DBT_TOKEN}" ]
then
echo trying to use DBT_TOKEN/databricks
sed -i "s/_token_/${DBT_TOKEN}/g" $PROFILES_FILE
else
echo cannot parse bigquery token
exit 1
echo no tokens or credentials supplied
fi

if [ -n "${INPUT_HTTP_PATH}" ]
then
echo trying to use http_path for databricks
sed -i "s/_http_path_/$(echo $INPUT_HTTP_PATH | sed 's/\//\\\//g')/g" $PROFILES_FILE
fi
elif [ -n "${DBT_USER}" ] && [ -n "$DBT_PASSWORD" ]
then
echo trying to use user/password
sed -i "s/_user_/${DBT_USER}/g" ./profiles.yml
sed -i "s/_password_/${DBT_PASSWORD}/g" ./profiles.yml
elif [ -n "${DBT_TOKEN}" ]
then
echo trying to use DBT_TOKEN/databricks
sed -i "s/_token_/${DBT_TOKEN}/g" ./datab.yml
elif [ -n "${INPUT_HTTP_PATH}" ]
then
echo trying to use http_path for databricks
sed -i "s/_http_path_/${INPUT_HTTP_PATH}/g" ./profiles.yml
else
echo no tokens or credentials supplied
echo "profiles.yml not found"
exit 1
fi

DBT_ACTION_LOG_FILE=${DBT_ACTION_LOG_FILE:="dbt_console_output.txt"}
Expand Down