@@ -23,7 +23,7 @@ SHELL:=/usr/bin/env bash
23
23
#
24
24
# Go.
25
25
#
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}')
27
27
GO_BASE_CONTAINER ?= docker.io/library/golang
28
28
GO_CONTAINER_IMAGE ?= $(GO_BASE_CONTAINER ) :$(GO_VERSION )
29
29
@@ -121,7 +121,7 @@ KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
121
121
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5
122
122
123
123
CLUSTER_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
125
125
126
126
MOCKGEN_VER := v0.4.0
127
127
MOCKGEN_BIN := mockgen
@@ -300,6 +300,8 @@ generate-modules: ## Run go mod tidy to ensure modules are up to date
300
300
301
301
.PHONY : download-cluster-api-crd
302
302
download-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 ) /*
303
305
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 )
304
306
chmod 644 $(CLUSTER_API_CRD_LOCATION ) /*
305
307
@@ -425,7 +427,7 @@ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILD
425
427
install-tools : $(ENVSUBST ) $(KUSTOMIZE ) $(HELM ) $(GINKGO ) # Should kubectl be added here?
426
428
427
429
.PHONY : test
428
- test : $(SETUP_ENVTEST ) # # Run unit and integration tests
430
+ test : $(SETUP_ENVTEST ) download-cluster-api-crd # # Run unit and integration tests
429
431
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test ./... $(TEST_ARGS )
430
432
431
433
.PHONY : test-verbose
0 commit comments