-
Notifications
You must be signed in to change notification settings - Fork 217
/
setup_env.sh
executable file
·104 lines (80 loc) · 3.7 KB
/
setup_env.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
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
set -o nounset
set -o pipefail
set -o errexit
set -o xtrace
function print_help() {
ALL_FUNCS="assisted_service|print_help"
echo "Usage: bash ${0} (${ALL_FUNCS})"
}
function spectral() {
echo "Installing spectral..."
curl --retry 5 --connect-timeout 30 -sL https://github.com/stoplightio/spectral/releases/download/v5.9.1/spectral-linux --output /usr/local/bin/spectral
chmod +x /usr/local/bin/spectral
}
function jq() {
echo "Installing jq..."
curl --retry 5 --connect-timeout 30 -sL https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 --output /usr/local/bin/jq
chmod +x /usr/local/bin/jq
}
function awscli() {
echo "Installing aws-cli..."
curl --retry 5 --connect-timeout 30 -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" --output "/tmp/awscliv2.zip"
unzip -q /tmp/awscliv2.zip
./aws/install
rm -f /tmp/awscliv2.zip
}
function podman_remote() {
# podman-remote 4 cannot run against podman server 3 so installing them both side by side
curl --retry 5 --connect-timeout 30 -L https://github.com/containers/podman/releases/download/v3.4.4/podman-remote-static.tar.gz -o "podman-remote3.tar.gz"
tar -zxvf podman-remote3.tar.gz
mv podman-remote-static /usr/local/bin/podman-remote3
rm -f podman-remote3.tar.gz
curl --retry 5 --connect-timeout 30 -L https://github.com/containers/podman/releases/download/v4.1.1/podman-remote-static.tar.gz -o "podman-remote4.tar.gz"
tar -zxvf podman-remote4.tar.gz
mv podman-remote-static /usr/local/bin/podman-remote4
rm -f podman-remote4.tar.gz
}
function envtest() {
# Branch 'release-0.17' is the newest version that can be installed with Go 1.21. This should be updated when we
# update the version of Go.
go install sigs.k8s.io/controller-runtime/tools/[email protected]
# The unit tests will try to use the 'setup-envtest' tool to download and locate the required assets. But that doesn't
# work in the CI environment because that tool saves the assets to a directory in the home of the user, which may not
# be writeable. To avoid that we download them here, and we move them to the default directory where the unit tests
# expect them.
src=$(setup-envtest use --print path 1.30.0)
dst="/usr/local/kubebuilder/bin"
mkdir -p "${dst}"
mv "${src}"/* "${dst}"/.
setup-envtest cleanup
}
function test_tools() {
go install github.com/onsi/ginkgo/[email protected]
go install github.com/golang/mock/[email protected]
go install github.com/vektra/mockery/[email protected]
go install gotest.tools/[email protected]
go install github.com/axw/gocov/[email protected]
go install github.com/AlekSi/[email protected]
envtest
}
function assisted_service() {
ARCH=$(case $(arch) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(arch) ;; esac)
OPERATOR_SDK_VERSION=v1.10.1
curl --retry 5 --connect-timeout 30 -sL "https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_$(uname)_${ARCH}" --output /usr/local/bin/operator-sdk
curl --retry 5 --connect-timeout 30 -sL "https://mirror.openshift.com/pub/openshift-v4/multi/clients/ocp/latest/${ARCH}/openshift-client-linux.tar.gz" | tar -C /usr/local/bin -xz
chmod +x /usr/local/bin/kubectl /usr/local/bin/oc /usr/local/bin/operator-sdk
dnf install -y unzip diffutils python3-pip genisoimage skopeo
dnf clean all && rm -rf /var/cache/yum
jq
awscli
spectral
test_tools
go install golang.org/x/tools/cmd/[email protected]
go install sigs.k8s.io/controller-tools/cmd/[email protected]
python3 -m venv ${VIRTUAL_ENV:-/opt/venv}
python3 -m pip install --upgrade pip
python3 -m pip install --no-cache-dir -r ./dev-requirements.txt
}
declare -F $@ || (print_help && exit 1)
"$@"