mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 10:00:11 +00:00
fix: replace broken kubebuilder-tools download with setup-envtest (#1390)
🤖 Generated with [Claude Code](https://claude.ai/code) Signed-off-by: Qing Hao <qhao@redhat.com> Co-authored-by: Qing Hao <qhao@redhat.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
558d5cb405
commit
267e8cfe94
@@ -3,23 +3,33 @@ TEST_TMP :=/tmp
|
||||
export KUBEBUILDER_ASSETS ?=$(TEST_TMP)/kubebuilder/bin
|
||||
|
||||
K8S_VERSION ?=1.30.0
|
||||
KB_TOOLS_ARCHIVE_NAME :=kubebuilder-tools-$(K8S_VERSION)-$(GOHOSTOS)-$(GOHOSTARCH).tar.gz
|
||||
KB_TOOLS_ARCHIVE_PATH := $(TEST_TMP)/$(KB_TOOLS_ARCHIVE_NAME)
|
||||
SETUP_ENVTEST := $(shell go env GOPATH)/bin/setup-envtest
|
||||
|
||||
# download the kubebuilder-tools to get kube-apiserver binaries from it
|
||||
ensure-kubebuilder-tools:
|
||||
ifeq "" "$(wildcard $(KUBEBUILDER_ASSETS))"
|
||||
$(info Downloading kube-apiserver into '$(KUBEBUILDER_ASSETS)')
|
||||
mkdir -p '$(KUBEBUILDER_ASSETS)'
|
||||
curl -s -f -L https://storage.googleapis.com/kubebuilder-tools/$(KB_TOOLS_ARCHIVE_NAME) -o '$(KB_TOOLS_ARCHIVE_PATH)'
|
||||
tar -C '$(KUBEBUILDER_ASSETS)' --strip-components=2 -zvxf '$(KB_TOOLS_ARCHIVE_PATH)'
|
||||
ifeq "" "$(wildcard $(SETUP_ENVTEST))"
|
||||
$(info Installing setup-envtest into '$(SETUP_ENVTEST)')
|
||||
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.22
|
||||
endif
|
||||
ENVTEST_K8S_PATH=$$($(SETUP_ENVTEST) use $(K8S_VERSION) --bin-dir $(KUBEBUILDER_ASSETS) -p path); \
|
||||
if [ -z "$$ENVTEST_K8S_PATH" ]; then \
|
||||
echo "Error: setup-envtest returned empty path"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if [ ! -d "$$ENVTEST_K8S_PATH" ]; then \
|
||||
echo "Error: setup-envtest path does not exist: $$ENVTEST_K8S_PATH"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
cp -r $$ENVTEST_K8S_PATH/* $(KUBEBUILDER_ASSETS)/
|
||||
else
|
||||
$(info Using existing kube-apiserver from "$(KUBEBUILDER_ASSETS)")
|
||||
endif
|
||||
.PHONY: ensure-kubebuilder-tools
|
||||
|
||||
clean-integration-test:
|
||||
$(RM) '$(KB_TOOLS_ARCHIVE_PATH)'
|
||||
rm -rf $(TEST_TMP)/kubebuilder
|
||||
$(RM) ./*integration.test
|
||||
.PHONY: clean-integration-test
|
||||
|
||||
Reference in New Issue
Block a user