-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.sh
executable file
·49 lines (43 loc) · 1.66 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function fail() {
local error="${*:-Unknown error}"
echo "$(chalk red "${error}")"
exit 1
}
joined_arguments=""
function build_and_run() {
local connector="$1"
if [[ $2 == "driver" ]]; then
path=drivers/$connector
elif [[ $2 == "adapter" ]]; then
path=adapters/$connector
else
fail "The argument does not have a recognized prefix."
fi
cd $path || fail "Failed to navigate to path: $path"
go mod tidy
go build -ldflags="-w -s -X constants/constants.version=${GIT_VERSION} -X constants/constants.commitsha=${GIT_COMMITSHA} -X constants/constants.releasechannel=${RELEASE_CHANNEL}" -o olake main.go || fail "build failed"
echo "============================== Executing connector: $connector with args [$joined_arguments] =============================="
./olake $joined_arguments
}
if [ $# -gt 0 ]; then
argument="$1"
# Capture and join remaining arguments, skipping the first one
remaining_arguments=("${@:2}")
joined_arguments=$(
IFS=' '
echo "${remaining_arguments[*]}"
)
if [[ $argument == driver-* ]]; then
driver="${argument#driver-}"
echo "============================== Building driver: $driver =============================="
build_and_run "$driver" "driver" "$joined_arguments"
elif [[ $argument == adapter-* ]]; then
adapter="${argument#adapter-}"
echo "============================== Building adapter: $adapter =============================="
build_and_run "$adapter" "adapter" "$joined_arguments"
else
fail "The argument does not have a recognized prefix."
fi
else
fail "No arguments provided."
fi