@@ -20,9 +20,12 @@ GO_TEST ?= $(GO) test
2020# by managing them together in the main module.
2121CONTROLLER ?= $(GO ) tool sigs.k8s.io/controller-tools/cmd/controller-gen
2222
23- KUTTL ?= kubectl-kuttl
23+ # Run tests using the latest tools.
24+ ENVTEST ?= $(GO ) run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
25+ KUTTL ?= $(GO ) run github.com/kudobuilder/kuttl/pkg/kuttlctl/cmd/kubectl-kuttl@latest
2426KUTTL_TEST ?= $(KUTTL ) test
2527
28+
2629# #@ General
2730
2831# The help target prints out all targets with their descriptions organized
@@ -67,7 +70,6 @@ clean: clean-deprecated
6770 rm -f bin/postgres-operator
6871 rm -rf licenses/* /
6972 [ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated
70- [ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest
7173 [ ! -d hack/tools/envtest ] || { chmod -R u+w hack/tools/envtest && rm -r hack/tools/envtest; }
7274 [ ! -d hack/tools/pgmonitor ] || rm -rf hack/tools/pgmonitor
7375 [ ! -d hack/tools/external-snapshotter ] || rm -rf hack/tools/external-snapshotter
@@ -97,6 +99,7 @@ clean-deprecated: ## Clean deprecated resources
9799 [ ! -d testing/kuttl/e2e-generated-other ] || rm -r testing/kuttl/e2e-generated-other
98100 @# Tools used to be downloaded directly
99101 [ ! -f hack/tools/controller-gen ] || rm hack/tools/controller-gen
102+ [ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest
100103
101104
102105# #@ Deployment
@@ -206,7 +209,7 @@ check: get-pgmonitor
206209check-envtest : # # Run check using envtest and a mock kube api
207210check-envtest : ENVTEST_USE = $(ENVTEST ) --bin-dir=$(CURDIR ) /hack/tools/envtest use $(ENVTEST_K8S_VERSION )
208211check-envtest : SHELL = bash
209- check-envtest : get-pgmonitor tools/setup-envtest
212+ check-envtest : get-pgmonitor
210213 @$(ENVTEST_USE ) --print=overview && echo
211214 source <( $( ENVTEST_USE) --print=env) && PGO_NAMESPACE=" postgres-operator" QUERIES_CONFIG_DIR=" $( CURDIR) /${QUERIES_CONFIG_DIR} " \
212215 $(GO_TEST ) -count=1 -cover ./...
@@ -299,20 +302,6 @@ generate-rbac: ## Generate RBAC
299302 paths=' ./cmd/...' paths=' ./internal/...' \
300303 output:dir=' config/rbac' # {directory}/role.yaml
301304
302- # #@ Tools
303-
304- .PHONY : tools
305- tools : # # Download tools like controller-gen and kustomize if necessary.
306-
307- # go-get-tool will 'go install' any package $2 and install it to $1.
308- define go-get-tool
309- @[ -f '$(1 ) ' ] || { echo Downloading '$(2 ) '; GOBIN='$(abspath $(dir $(1 ) ) ) ' $(GO ) install '$(2 ) '; }
310- endef
311-
312- ENVTEST ?= hack/tools/setup-envtest
313- tools : tools/setup-envtest
314- tools/setup-envtest :
315- $(call go-get-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
316305
317306# #@ Release
318307
0 commit comments