Skip to content

Commit c5ec23d

Browse files
authored
Merge pull request #75 from edenlabllc/release/v2.1.0
Release/v2.1.0
2 parents 73d6e9b + fb45fe8 commit c5ec23d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

bin/postsync-call-mongosync-api.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
readonly NAMESPACE="${1}"
6+
readonly RELEASE_NAME="${2}"
7+
readonly COMMAND="${3:-start}"
8+
readonly START_PAYLOAD="${4:-{\"source\":\"cluster0\",\"destination\":\"cluster1\"}}"
9+
10+
function cmd() {
11+
kubectl -n "${NAMESPACE}" exec "deploy/${RELEASE_NAME}" -- "${@}"
12+
}
13+
14+
function check_status() {
15+
local STATUS="$(cmd curl --max-time 10 --silent http://localhost:27182/api/v1/progress | yq '.success')"
16+
17+
if [[ "${STATUS}" != "true" ]]; then
18+
>&2 echo "Mongosync not ready or failed."
19+
exit 1
20+
fi
21+
}
22+
23+
case "${COMMAND}" in
24+
commit)
25+
check_status
26+
cmd curl --max-time 10 --silent http://localhost:27182/api/v1/commit -XPOST --data '{}'
27+
;;
28+
pause)
29+
check_status
30+
cmd curl --max-time 10 --silent http://localhost:27182/api/v1/pause -XPOST --data '{}'
31+
;;
32+
resume)
33+
check_status
34+
cmd curl --max-time 10 --silent http://localhost:27182/api/v1/resume -XPOST --data '{}'
35+
;;
36+
start)
37+
check_status
38+
cmd curl --max-time 10 --silent http://localhost:27182/api/v1/start -XPOST --data "${START_PAYLOAD}"
39+
;;
40+
*)
41+
>&2 echo "Incorrect command name ${COMMAND}; available commands: commit, pause, resume, start."
42+
exit 1
43+
;;
44+
esac

0 commit comments

Comments
 (0)