From 947c98d442722212db824f32e44619ba79cd63bc Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Mon, 5 Feb 2024 13:21:45 -0500 Subject: [PATCH] fix: allow to setup private dbt repository --- tutoraspects/plugin.py | 1 + .../templates/aspects/apps/aspects/scripts/dbt.sh | 9 +++++++++ .../templates/aspects/jobs/init/aspects/init-aspects.sh | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/tutoraspects/plugin.py b/tutoraspects/plugin.py index 7b2495873..1e8051773 100644 --- a/tutoraspects/plugin.py +++ b/tutoraspects/plugin.py @@ -352,6 +352,7 @@ # flexibility for forking, running branches, specific versions, etc. ("DBT_REPOSITORY", "https://github.com/openedx/aspects-dbt"), ("DBT_BRANCH", "v3.4.1"), + ("DBT_SSH_KEY", ""), # Path to the dbt project inside the repository ("DBT_REPOSITORY_PATH", "aspects-dbt"), # This is a pip compliant list of Python packages to install to run dbt diff --git a/tutoraspects/templates/aspects/apps/aspects/scripts/dbt.sh b/tutoraspects/templates/aspects/apps/aspects/scripts/dbt.sh index 1c9ad343c..27b262fc3 100644 --- a/tutoraspects/templates/aspects/apps/aspects/scripts/dbt.sh +++ b/tutoraspects/templates/aspects/apps/aspects/scripts/dbt.sh @@ -7,6 +7,15 @@ echo "Installing dbt packages..." pip install -r /app/aspects/dbt/requirements.txt +{% if DBT_SSH_KEY %} +mkdir -p /root/.ssh +echo "{{ DBT_SSH_KEY}}" | tr -d '\r' > /root/.ssh/id_rsa +chmod 600 /root/.ssh/id_rsa +eval `ssh-agent -s` +ssh -o StrictHostKeyChecking=no git@github.com || true +ssh-add /root/.ssh/id_rsa +{% endif %} + rm -rf {{ DBT_REPOSITORY_PATH }} echo "Installing aspects-dbt" diff --git a/tutoraspects/templates/aspects/jobs/init/aspects/init-aspects.sh b/tutoraspects/templates/aspects/jobs/init/aspects/init-aspects.sh index 6c35a27d0..f843b09ff 100644 --- a/tutoraspects/templates/aspects/jobs/init/aspects/init-aspects.sh +++ b/tutoraspects/templates/aspects/jobs/init/aspects/init-aspects.sh @@ -16,6 +16,15 @@ echo "Installing dbt packages..." pip install -r /app/aspects/dbt/requirements.txt +{% if DBT_SSH_KEY %} +mkdir -p /root/.ssh +echo "{{ DBT_SSH_KEY}}" | tr -d '\r' > /root/.ssh/id_rsa +chmod 600 /root/.ssh/id_rsa +eval `ssh-agent -s` +ssh -o StrictHostKeyChecking=no git@github.com || true +ssh-add /root/.ssh/id_rsa +{% endif %} + rm -rf {{ DBT_REPOSITORY_PATH }} echo "Installing aspects-dbt"