@@ -128,10 +128,31 @@ vet: ## Run go vet against code.
128128test : manifests generate fmt vet setup-envtest # # Run tests.
129129 KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go test $$(go list ./... | grep -v /e2e ) -coverprofile cover.out
130130
131+ KIND_CLUSTER ?= github-token-manager-test-e2e
132+
133+ .PHONY : setup-test-e2e
134+ setup-test-e2e : # # Set up a Kind cluster for e2e tests if it does not exist
135+ @command -v $(KIND ) > /dev/null 2>&1 || { \
136+ echo " Kind is not installed. Please install Kind manually." ; \
137+ exit 1; \
138+ }
139+ @case " $$ ($( KIND) get clusters)" in \
140+ * " $( KIND_CLUSTER) " * ) \
141+ echo " Kind cluster '$( KIND_CLUSTER) ' already exists. Skipping creation." ;; \
142+ * ) \
143+ echo " Creating Kind cluster '$( KIND_CLUSTER) '..." ; \
144+ $(KIND ) create cluster --name $(KIND_CLUSTER ) ;; \
145+ esac
146+
147+ .PHONY : cleanup-test-e2e
148+ cleanup-test-e2e :
149+ $(KIND ) delete cluster --name $(KIND_CLUSTER )
150+
131151# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
132- .PHONY : test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
133- test-e2e :
134- go test ./test/e2e/ -v -ginkgo.v
152+ .PHONY : test-e2e
153+ test-e2e : setup-test-e2e manifests generate fmt vet # # Run the e2e tests. Expected an isolated environment using Kind.
154+ KIND_CLUSTER=$(KIND_CLUSTER ) go test ./test/e2e/ -v -ginkgo.v
155+ $(MAKE ) cleanup-test-e2e
135156
136157.PHONY : lint
137158lint : golangci-lint # # Run golangci-lint linter
@@ -227,16 +248,17 @@ $(LOCALBIN):
227248
228249# # Tool Binaries
229250KUBECTL ?= kubectl
251+ KIND ?= kind
230252KUSTOMIZE ?= $(LOCALBIN ) /kustomize
231253CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
232254ENVTEST ?= $(LOCALBIN ) /setup-envtest
233255GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
234256
235257# # Tool Versions
236258KUSTOMIZE_VERSION ?= v5.5.0
237- CONTROLLER_TOOLS_VERSION ?= v0.16.4
259+ CONTROLLER_TOOLS_VERSION ?= v0.18.0
238260ENVTEST_VERSION := $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-% d.% d", $$2, $$3}')
239- GOLANGCI_LINT_VERSION ?= v1.59.1
261+ GOLANGCI_LINT_VERSION ?= v2.1.0
240262
241263.PHONY : kustomize
242264kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -264,7 +286,7 @@ $(ENVTEST): $(LOCALBIN)
264286.PHONY : golangci-lint
265287golangci-lint : $(GOLANGCI_LINT ) # # Download golangci-lint locally if necessary.
266288$(GOLANGCI_LINT ) : $(LOCALBIN )
267- $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
289+ $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/v2/ cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
268290
269291# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
270292# $1 - target path with name of binary
0 commit comments