Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 6065b42

Browse files
committed
build: Use setup-envtest to download later version of envtest
`controller-runtime` provides a convenient tool to download various versions of k8s. This commit switches to using that to ensure we use a single version for testing in unit tests and in e2e tests, namely v1.21.x right now so to keep the version stable while just changing the installation mechanism.
1 parent 3b77f67 commit 6065b42

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ all: container hyperfed controller kubefedctl webhook e2e
7676

7777
# Unit tests
7878
test:
79-
go test $(TEST_PKGS)
79+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
80+
source <(setup-envtest use -p env 1.21.x) && \
81+
go test $(TEST_PKGS)
8082

8183
build: hyperfed controller kubefedctl webhook
8284

scripts/download-binaries.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,29 @@ kb_url="https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${kb_v
4949
curl "${curl_args}" "${kb_url}" \
5050
| tar xzP -C "${dest_dir}" --strip-components=2
5151

52-
export KUBEBUILDER_ASSETS="${dest_dir}"
53-
echo "Setting to KUBEBUILDER_ASSETS ${dest_dir}"
52+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
53+
source <(setup-envtest use -p env 1.21.x)
54+
55+
echo "KUBEBUILDER_ASSETS is set to ${KUBEBUILDER_ASSETS}"
5456

5557
helm_version="3.6.0"
5658
helm_tgz="helm-v${helm_version}-${platform}-amd64.tar.gz"
5759
helm_url="https://get.helm.sh/$helm_tgz"
5860
curl "${curl_args}" "${helm_url}" \
5961
| tar xzP -C "${dest_dir}" --strip-components=1 "${platform}-amd64/helm"
6062

63+
kubectl_version="v1.21.14"
64+
curl -Lo "${dest_dir}/kubectl" "https://dl.k8s.io/release/${kubectl_version}/bin/${platform}/amd64/kubectl"
65+
(cd "${dest_dir}" && \
66+
echo "$(curl -L "https://dl.k8s.io/release/${kubectl_version}/bin/${platform}/amd64/kubectl.sha256") kubectl" | \
67+
sha256sum --check
68+
)
69+
chmod +x "${dest_dir}/kubectl"
70+
71+
kubebuilder_version="2.3.2"
72+
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${kubebuilder_version}/kubebuilder_${kubebuilder_version}_${platform}_amd64.tar.gz | \
73+
tar xzP -C "${dest_dir}" --strip-components=2 -- "kubebuilder_${kubebuilder_version}_${platform}_amd64/bin/kubebuilder"
74+
6175
golint_version="1.40.1"
6276
golint_dir="golangci-lint-${golint_version}-${platform}-amd64"
6377
golint_tgz="${golint_dir}.tar.gz"

0 commit comments

Comments
 (0)