-
Notifications
You must be signed in to change notification settings - Fork 136
/
install.sh
94 lines (85 loc) · 2.32 KB
/
install.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
echo "Getting kubectl-testkube plugin"
if [ ! -z "${DEBUG}" ];
then set -x
fi
_detect_arch() {
case $(uname -m) in
amd64|x86_64) echo "x86_64"
;;
arm64|aarch64) echo "arm64"
;;
i386) echo "i386"
;;
*) echo "Unsupported processor architecture";
return 1
;;
esac
}
_detect_os(){
case $(uname) in
Linux) echo "Linux"
;;
Darwin) echo "Darwin"
;;
Windows) echo "Windows"
;;
esac
}
_download_url() {
local arch
local os
local tag
local version
arch="$(_detect_arch)"
os="$(_detect_os)"
if [ -z "$TESTKUBE_VERSION" ]; then
if [ "$1" = "beta" ]; then
tag="$(
curl -s "https://api.github.com/repos/kubeshop/testkube/releases" \
2>/dev/null \
| jq -r '.[].tag_name | select(test("beta"))' \
| head -n 1 \
)"
if [ -z "$tag" ]; then
echo "No beta releases found. Installing latest release" >&2
tag="$(
curl -s "https://api.github.com/repos/kubeshop/testkube/releases/latest" \
2>/dev/null \
| jq -r '.tag_name' \
)"
fi
else
tag="$(
curl -s "https://api.github.com/repos/kubeshop/testkube/releases/latest" \
2>/dev/null \
| jq -r '.tag_name' \
)"
fi
else
tag="$TESTKUBE_VERSION"
fi
version="${tag/#v/}" # remove leading v if present
echo "https://github.com/kubeshop/testkube/releases/download/${tag}/testkube_${version:-1}_${os}_$arch.tar.gz"
}
if [ "$1" = "beta" ]; then
url="$(_download_url "beta")"
echo "Downloading testkube from URL: $url"
curl -sSLf "$url" > testkube.tar.gz
else
echo "Downloading testkube from URL: $(_download_url)"
curl -sSLf "$(_download_url)" > testkube.tar.gz
fi
tar -xzf testkube.tar.gz kubectl-testkube
rm testkube.tar.gz
mv kubectl-testkube /usr/local/bin/kubectl-testkube
ln -s /usr/local/bin/kubectl-testkube /usr/local/bin/testkube
ln -s /usr/local/bin/kubectl-testkube /usr/local/bin/tk
echo "kubectl-testkube installed in:"
echo "- /usr/local/bin/kubectl-testkube"
echo "- /usr/local/bin/testkube"
echo "- /usr/local/bin/tk"
echo ""
echo "You'll also need `helm` and Kubernetes `kubectl` installed."
echo "- Install Helm: https://helm.sh/docs/intro/install/"
echo "- Install kubectl: https://kubernetes.io/docs/tasks/tools/#kubectl"