Skip to content

Commit

Permalink
Development/alex/add branch support to install template (#64)
Browse files Browse the repository at this point in the history
* Added support for install-template --branch option

* Prevent failure on version.sbt not existing

* Add destroy playbooks back to migration
  • Loading branch information
AlexBrandes authored Feb 4, 2025
1 parent ed18a6b commit 0cff462
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion infra/docker/metagraph-ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN apt-get update && \
RUN git clone https://github.com/Constellation-Labs/tessellation.git && \
cd tessellation && \
git checkout $CHECKOUT_TESSELLATION_VERSION && \
rm -r version.sbt && \
rm -rf version.sbt && \
echo "ThisBuild / version := \"$TESSELLATION_VERSION_SEMVER\"" > version.sbt

RUN cd tessellation && \
Expand Down
3 changes: 2 additions & 1 deletion scripts/hydra
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function install() {

# @cmd Installs a project from templates
# @arg name Project name
# @option --repo Project repositor (default https://github.com/Constellation-Labs/metagraph-examples.git)
# @option --repo Project repository (default https://github.com/Constellation-Labs/metagraph-examples.git)
# @option --branch Repository branch (default default_branch)
# @option --path Template path on repository (default examples)
# @flag --list List available templates
function install-template() {
Expand Down
27 changes: 21 additions & 6 deletions scripts/hydra-operations/install-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ function install_template() {
rm -r -f $INFRA_PATH/$repo_name
git clone --quiet $argc_repo >/dev/null

if [ "${argc_branch}" ]; then
echo_yellow "Using branch ${argc_branch}"
cd $INFRA_PATH/$repo_name
git checkout --quiet $argc_branch >/dev/null
cd ../
fi

echo_yellow ""
echo_yellow "Available templates"
echo_green ""
echo_green "=== Available Templates ==="
ls -1 $INFRA_PATH/$repo_name/$argc_path

rm -rf $INFRA_PATH/$repo_name
Expand All @@ -22,21 +28,29 @@ function install_template() {
fi

if [ -z "${argc_name}" ]; then
echo_red "You should provide the repository name"
echo_red "You must provide a repository name"
exit 1
fi

echo_green "##########################################"
echo_url "=== Template Details ==="
echo_url "Project name:" $argc_name
echo_url "Repository URL:" $argc_repo
echo_url "Repository Name:" $repo_name
echo_url "Path:" $argc_path
echo_green "##########################################"

cd $INFRA_PATH
rm -r -f $INFRA_PATH/$repo_name
git clone --quiet $argc_repo >/dev/null

if [ "${argc_branch}" ]; then
echo_url "Branch: " $argc_branch
cd $INFRA_PATH/$repo_name
git checkout --quiet $argc_branch >/dev/null
cd ../
fi

echo_green ""

echo_white "Checking if the template exists on repository..."
PROJECT_DIRECTORY=$repo_name/$argc_path/$argc_name
if [ ! -d "$PROJECT_DIRECTORY" ]; then
Expand Down Expand Up @@ -71,5 +85,6 @@ function install_template() {
rm -r .git
fi


echo_green ""
echo_url "Template installed: " $argc_name
}
4 changes: 4 additions & 0 deletions scripts/hydra-operations/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function check_if_should_update() {
echo "Directory - scripts"
echo "Directory - infra/ansible/local/playbooks/start"
echo "Directory - infra/ansible/local/playbooks/stop"
echo "Directory - infra/ansible/local/playbooks/destroy"
echo "File - infra/ansible/local/playbooks/vars.ansible.yml"
echo "Directory - infra/ansible/remote/nodes/playbooks/deploy"
echo "Directory - infra/ansible/remote/nodes/playbooks/start"
Expand Down Expand Up @@ -136,6 +137,9 @@ function update_local_ansible_files() {
rm -r $ANSIBLE_DIRECTORY/playbooks/stop
cp -r $INFRA_PATH/euclid-development-environment/infra/ansible/local/playbooks/stop $ANSIBLE_DIRECTORY/playbooks

rm -r $ANSIBLE_DIRECTORY/playbooks/destroy
cp -r $INFRA_PATH/euclid-development-environment/infra/ansible/local/playbooks/destroy $ANSIBLE_DIRECTORY/playbooks

else
mkdir -p "$INFRA_PATH/ansible"
cp -r $INFRA_PATH/euclid-development-environment/infra/ansible/local "$INFRA_PATH/ansible"
Expand Down

0 comments on commit 0cff462

Please sign in to comment.