Skip to content

Commit 36525c9

Browse files
haoqing0110claude
andauthored
fix: replace archive download with setup-envtest for kubebuilder-tools (#363)
🤖 Generated with [Claude Code](https://claude.ai/code) Signed-off-by: Qing Hao <qhao@redhat.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 348aab3 commit 36525c9

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

test/integration-test.mk

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,33 @@ TEST_TMP :=/tmp
33
export KUBEBUILDER_ASSETS ?=$(TEST_TMP)/kubebuilder/bin
44

55
K8S_VERSION ?=1.30.0
6-
KB_TOOLS_ARCHIVE_NAME :=kubebuilder-tools-$(K8S_VERSION)-$(GOHOSTOS)-$(GOHOSTARCH).tar.gz
7-
KB_TOOLS_ARCHIVE_PATH := $(TEST_TMP)/$(KB_TOOLS_ARCHIVE_NAME)
6+
SETUP_ENVTEST := $(shell go env GOPATH)/bin/setup-envtest
87

98
# download the kubebuilder-tools to get kube-apiserver binaries from it
109
ensure-kubebuilder-tools:
1110
ifeq "" "$(wildcard $(KUBEBUILDER_ASSETS))"
1211
$(info Downloading kube-apiserver into '$(KUBEBUILDER_ASSETS)')
1312
mkdir -p '$(KUBEBUILDER_ASSETS)'
14-
curl -s -f -L https://storage.googleapis.com/kubebuilder-tools/$(KB_TOOLS_ARCHIVE_NAME) -o '$(KB_TOOLS_ARCHIVE_PATH)'
15-
tar -C '$(KUBEBUILDER_ASSETS)' --strip-components=2 -zvxf '$(KB_TOOLS_ARCHIVE_PATH)'
13+
ifeq "" "$(wildcard $(SETUP_ENVTEST))"
14+
$(info Installing setup-envtest into '$(SETUP_ENVTEST)')
15+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.22
16+
endif
17+
ENVTEST_K8S_PATH=$$($(SETUP_ENVTEST) use $(K8S_VERSION) --bin-dir $(KUBEBUILDER_ASSETS) -p path); \
18+
if [ -z "$$ENVTEST_K8S_PATH" ]; then \
19+
echo "Error: setup-envtest returned empty path"; \
20+
exit 1; \
21+
fi; \
22+
if [ ! -d "$$ENVTEST_K8S_PATH" ]; then \
23+
echo "Error: setup-envtest path does not exist: $$ENVTEST_K8S_PATH"; \
24+
exit 1; \
25+
fi; \
26+
cp -r $$ENVTEST_K8S_PATH/* $(KUBEBUILDER_ASSETS)/
1627
else
1728
$(info Using existing kube-apiserver from "$(KUBEBUILDER_ASSETS)")
1829
endif
1930
.PHONY: ensure-kubebuilder-tools
2031

2132
clean-integration-test:
22-
$(RM) '$(KB_TOOLS_ARCHIVE_PATH)'
2333
rm -rf $(TEST_TMP)/kubebuilder
2434
$(RM) ./integration.test
2535
.PHONY: clean-integration-test

0 commit comments

Comments
 (0)