Skip to content

Commit

Permalink
Remove private bindings when compile script finishes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Dec 9, 2024
1 parent 4b094ef commit 557e518
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
9 changes: 1 addition & 8 deletions ci/add_private_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,4 @@ bindings_name=$1
bindings_path=$2

go mod edit -require="$bindings_name"@v0.0.0
go mod edit -replace="$bindings_name"="$bindings_path"

function revert_private_bindings {
go mod edit -droprequire="$bindings_name"
go mod edit -dropreplace="$bindings_name"
}

trap revert_private_bindings EXIT
go mod edit -replace="$bindings_name"="$bindings_path"
8 changes: 7 additions & 1 deletion ci/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ tags="${FEATURES:-"telio drop"}"
source "${WORKDIR}"/ci/set_bindings_version.sh libtelio
source "${WORKDIR}"/ci/set_bindings_version.sh libdrop

private_bindings_rollback=""
trap -- '${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker; ${WORKDIR}/ci/remove_private_bindings.sh quench' EXIT
if [[ $tags == *"moose"* ]]; then
# Set correct events domain in case compiling with moose
if [[ "${ENVIRONMENT}" == "prod" ]]; then
Expand All @@ -74,12 +76,16 @@ if [[ $tags == *"moose"* ]]; then
-X 'main.EventsDomain=${events_domain:-""}' \
-X 'main.EventsSubdomain=${EVENTS_SUBDOMAIN:-""}'"

# private_bindings_rollback="${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker;"
# trap -- "$private_bindings_rollback" EXIT
source "${WORKDIR}"/ci/add_private_bindings.sh moose/events ./third-party/moose-events/moosenordvpnappgo/v14
source "${WORKDIR}"/ci/add_private_bindings.sh moose/worker ./third-party/moose-worker/mooseworkergo/v14
fi

if [[ $tags == *"quench"* ]]; then
source "${WORKDIR}"/ci/add_private_bindings.sh quench ./third-party/libquench-go
private_bindings_rollback="${private_bindings_rollback} ${WORKDIR}/ci/remove_private_bindings.sh quench"
# trap -- "$private_bindings_rollback" EXIT
# source "${WORKDIR}"/ci/add_private_bindings.sh quench ./third-party/libquench-go
fi

for program in ${!names_map[*]}; do # looping over keys
Expand Down
6 changes: 6 additions & 0 deletions ci/remove_private_bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

bindings_name=$1

go mod edit -droprequire="$bindings_name"
go mod edit -dropreplace="$bindings_name"
1 change: 1 addition & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tags="internal"
# everything
if [ "${1:-""}" = "full" ]; then
# Apply moose patch in case compiling with moose
trap '${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker;' EXIT
source "${WORKDIR}"/ci/add_private_bindings.sh moose/events ./third-party/moose-events/moosenordvpnappgo/v14
source "${WORKDIR}"/ci/add_private_bindings.sh moose/worker ./third-party/moose-worker/mooseworkergo/v14

Expand Down

0 comments on commit 557e518

Please sign in to comment.