Skip to content

Commit e2b5328

Browse files
Remove private bindings when compile script finishes
1 parent 4b094ef commit e2b5328

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

ci/add_private_bindings.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,4 @@ bindings_name=$1
44
bindings_path=$2
55

66
go mod edit -require="$bindings_name"@v0.0.0
7-
go mod edit -replace="$bindings_name"="$bindings_path"
8-
9-
function revert_private_bindings {
10-
go mod edit -droprequire="$bindings_name"
11-
go mod edit -dropreplace="$bindings_name"
12-
}
13-
14-
trap revert_private_bindings EXIT
7+
go mod edit -replace="$bindings_name"="$bindings_path"

ci/compile.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ tags="${FEATURES:-"telio drop"}"
6262
source "${WORKDIR}"/ci/set_bindings_version.sh libtelio
6363
source "${WORKDIR}"/ci/set_bindings_version.sh libdrop
6464

65+
private_bindings_rollback=""
6566
if [[ $tags == *"moose"* ]]; then
6667
# Set correct events domain in case compiling with moose
6768
if [[ "${ENVIRONMENT}" == "prod" ]]; then
@@ -74,11 +75,15 @@ if [[ $tags == *"moose"* ]]; then
7475
-X 'main.EventsDomain=${events_domain:-""}' \
7576
-X 'main.EventsSubdomain=${EVENTS_SUBDOMAIN:-""}'"
7677

78+
private_bindings_rollback="${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker;"
79+
trap "$private_bindings_rollback" EXIT
7780
source "${WORKDIR}"/ci/add_private_bindings.sh moose/events ./third-party/moose-events/moosenordvpnappgo/v14
7881
source "${WORKDIR}"/ci/add_private_bindings.sh moose/worker ./third-party/moose-worker/mooseworkergo/v14
7982
fi
8083

8184
if [[ $tags == *"quench"* ]]; then
85+
private_bindings_rollback="${private_bindings_rollback} ${WORKDIR}/ci/remove_private_bindings.sh quench"
86+
trap "$private_bindings_rollback" EXIT
8287
source "${WORKDIR}"/ci/add_private_bindings.sh quench ./third-party/libquench-go
8388
fi
8489

ci/remove_private_bindings.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
bindings_name=$1
4+
5+
go mod edit -droprequire="$bindings_name"
6+
go mod edit -dropreplace="$bindings_name"

ci/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tags="internal"
1818
# everything
1919
if [ "${1:-""}" = "full" ]; then
2020
# Apply moose patch in case compiling with moose
21+
trap "${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker;" EXIT
2122
source "${WORKDIR}"/ci/add_private_bindings.sh moose/events ./third-party/moose-events/moosenordvpnappgo/v14
2223
source "${WORKDIR}"/ci/add_private_bindings.sh moose/worker ./third-party/moose-worker/mooseworkergo/v14
2324

0 commit comments

Comments
 (0)