@@ -23,7 +23,7 @@ SHELL:=/usr/bin/env bash
2323#
2424# Go.
2525#
26- GO_VERSION ?= 1.22.9
26+ GO_VERSION ?= $( shell go mod edit --print | grep -oP '(?<=toolchain go) .*' || go mod edit --print | grep "go " | head -1 | awk '{print $$2}')
2727GO_BASE_CONTAINER ?= docker.io/library/golang
2828GO_CONTAINER_IMAGE ?= $(GO_BASE_CONTAINER ) :$(GO_VERSION )
2929
@@ -121,7 +121,7 @@ KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
121121KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5
122122
123123CLUSTER_API_VERSION := $(call get_go_version,sigs.k8s.io/cluster-api)
124- CLUSTER_API_CRD_LOCATION = test/controllers/data /crd
124+ CLUSTER_API_CRD_LOCATION = tmp/cluster-api /crd
125125
126126MOCKGEN_VER := v0.4.0
127127MOCKGEN_BIN := mockgen
@@ -300,6 +300,8 @@ generate-modules: ## Run go mod tidy to ensure modules are up to date
300300
301301.PHONY : download-cluster-api-crd
302302download-cluster-api-crd : generate-modules # # Run to download Cluster API CRDs for tests
303+ mkdir -p $(CLUSTER_API_CRD_LOCATION )
304+ rm -f $(CLUSTER_API_CRD_LOCATION ) /*
303305 cp -r $(shell go env GOPATH) /pkg/mod/sigs.k8s.io/cluster-api@$(CLUSTER_API_VERSION ) /config/crd/bases/cluster.x-k8s.io_clusters.yaml $(CLUSTER_API_CRD_LOCATION )
304306 chmod 644 $(CLUSTER_API_CRD_LOCATION ) /*
305307
@@ -425,7 +427,7 @@ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILD
425427install-tools : $(ENVSUBST ) $(KUSTOMIZE ) $(HELM ) $(GINKGO ) # Should kubectl be added here?
426428
427429.PHONY : test
428- test : $(SETUP_ENVTEST ) # # Run unit and integration tests
430+ test : $(SETUP_ENVTEST ) download-cluster-api-crd # # Run unit and integration tests
429431 KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test ./... $(TEST_ARGS )
430432
431433.PHONY : test-verbose
0 commit comments