-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.sh
More file actions
executable file
·60 lines (55 loc) · 1.81 KB
/
tools.sh
File metadata and controls
executable file
·60 lines (55 loc) · 1.81 KB
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
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# Entrypoint of dev tools.
#
set -e
set -o pipefail
readonly d="$(cd "$(dirname "$0")" || exit ; pwd)"
readonly name="$1"
if [[ -z "$name" ]] ; then
echo >&2 "$(basename "$0"): no tool name!"
exit 1
fi
shift
# Install the tool.
# If a tool called by this script does not exist, its binary must be installed.
readonly toold="${d}/tools"
find_package() {
grep "$1" "${toold}/go.mod" | grep -v 'indirect' | xargs
}
readonly bind="${d}/../bin"
mkdir -p "${bind}"
readonly binary="${bind}/${name}"
case "$name" in
"helm")
# The build took too long when helm was incorporated into our tools, so we download the binary directly instead.
"${d}/setup-helm.sh" "$HELM_VERSION"
;;
"go-licenses")
# Separated from tools/ because the build won't pass, probably due to an outdated Go version.
"${d}/setup-go-licenses.sh"
;;
"pandoc")
"${d}/setup-pandoc.sh" "$PANDOC_VERSION"
;;
"setup-envtest")
# setup-envtest requires a dedicated setup because of its dependencies on other library versions.
"${d}/setup-envtest.sh"
# You don't need to pass any particular arguments to run this.
exit
;;
"kubectl")
# To avoid an excessive number of dependencies, we download the kubectl binary rather than managing it as part of tools/.
"${d}/setup-kubectl.sh" "$KUBECTL_VERSION"
;;
*)
# Some tools rely on the calling directory, so invoking them directly from go tool can lead to unintended results.
# Therefore, we build the binary first and then execute it.
if [[ ! -x "$binary" ]] ; then
echo >&2 "$(basename "$0"): build ${binary}..."
go -C "$toold" build -o "$binary" "$(find_package "$name")"
fi
;;
esac
# Run the tool
"$binary" "$@"