File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ if [[ "${TRACE-0}" == "1" ]]; then
22
22
set -o xtrace
23
23
fi
24
24
25
+ # shellcheck source=./hack/utils.sh
26
+ source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
27
+
25
28
# Ensure the go tool exists and is a viable version.
26
29
verify_go_version () {
27
30
if [[ -z " $( command -v go) " ]]; then
46
49
fi
47
50
}
48
51
52
+
49
53
verify_go_version
54
+ verify_gopath_bin
50
55
51
56
# Explicitly opt into go modules, even though we're inside a GOPATH directory
52
57
export GO111MODULE=on
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ if [[ "${TRACE-0}" == "1" ]]; then
22
22
set -o xtrace
23
23
fi
24
24
25
+ # shellcheck source=./hack/utils.sh
26
+ source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
27
+
25
28
GOPATH_BIN=" $( go env GOPATH) /bin"
26
29
MINIMUM_KIND_VERSION=v0.17.0
27
30
goarch=" $( go env GOARCH) "
@@ -39,6 +42,7 @@ verify_kind_version() {
39
42
fi
40
43
curl -sLo " ${GOPATH_BIN} /kind" " https://github.com/kubernetes-sigs/kind/releases/download/${MINIMUM_KIND_VERSION} /kind-${goos} -${goarch} "
41
44
chmod +x " ${GOPATH_BIN} /kind"
45
+ verify_gopath_bin
42
46
else
43
47
echo " Missing required binary in path: kind"
44
48
return 2
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ if [[ "${TRACE-0}" == "1" ]]; then
22
22
set -o xtrace
23
23
fi
24
24
25
+
26
+ # shellcheck source=./hack/utils.sh
27
+ source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
28
+
25
29
GOPATH_BIN=" $( go env GOPATH) /bin/"
26
30
MINIMUM_KUBECTL_VERSION=v1.19.0
27
31
goarch=" $( go env GOARCH) "
@@ -39,6 +43,7 @@ verify_kubectl_version() {
39
43
echo ' kubectl not found, installing'
40
44
curl -sLo " ${GOPATH_BIN} /kubectl" " https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION} /bin/${goos} /${goarch} /kubectl"
41
45
chmod +x " ${GOPATH_BIN} /kubectl"
46
+ verify_gopath_bin
42
47
else
43
48
echo " Missing required binary in path: kubectl"
44
49
return 2
Original file line number Diff line number Diff line change @@ -32,3 +32,18 @@ get_capd_root_path() {
32
32
cd_capd_root_path () {
33
33
cd " $( get_capd_root_path) " || exit
34
34
}
35
+
36
+ # ensure GOPATH/bin is in PATH as we may install binaries to that directory in
37
+ # other ensure-* scripts, and expect them to be found in PATH later on
38
+ verify_gopath_bin () {
39
+ local gopath_bin
40
+
41
+ gopath_bin=" $( go env GOPATH) /bin"
42
+ if ! printenv PATH | grep -q " ${gopath_bin} " ; then
43
+ cat << EOF
44
+ error: \$ GOPATH/bin=${gopath_bin} is not in your PATH.
45
+ See https://go.dev/doc/gopath_code for more instructions.
46
+ EOF
47
+ return 2
48
+ fi
49
+ }
You can’t perform that action at this time.
0 commit comments