@@ -20,9 +20,12 @@ GO_TEST ?= $(GO) test
20
20
# by managing them together in the main module.
21
21
CONTROLLER ?= $(GO ) tool sigs.k8s.io/controller-tools/cmd/controller-gen
22
22
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
24
26
KUTTL_TEST ?= $(KUTTL ) test
25
27
28
+
26
29
# #@ General
27
30
28
31
# The help target prints out all targets with their descriptions organized
@@ -67,7 +70,6 @@ clean: clean-deprecated
67
70
rm -f bin/postgres-operator
68
71
rm -rf licenses/* /
69
72
[ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated
70
- [ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest
71
73
[ ! -d hack/tools/envtest ] || { chmod -R u+w hack/tools/envtest && rm -r hack/tools/envtest; }
72
74
[ ! -d hack/tools/pgmonitor ] || rm -rf hack/tools/pgmonitor
73
75
[ ! -d hack/tools/external-snapshotter ] || rm -rf hack/tools/external-snapshotter
@@ -97,6 +99,7 @@ clean-deprecated: ## Clean deprecated resources
97
99
[ ! -d testing/kuttl/e2e-generated-other ] || rm -r testing/kuttl/e2e-generated-other
98
100
@# Tools used to be downloaded directly
99
101
[ ! -f hack/tools/controller-gen ] || rm hack/tools/controller-gen
102
+ [ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest
100
103
101
104
102
105
# #@ Deployment
@@ -206,7 +209,7 @@ check: get-pgmonitor
206
209
check-envtest : # # Run check using envtest and a mock kube api
207
210
check-envtest : ENVTEST_USE = $(ENVTEST ) --bin-dir=$(CURDIR ) /hack/tools/envtest use $(ENVTEST_K8S_VERSION )
208
211
check-envtest : SHELL = bash
209
- check-envtest : get-pgmonitor tools/setup-envtest
212
+ check-envtest : get-pgmonitor
210
213
@$(ENVTEST_USE ) --print=overview && echo
211
214
source <( $( ENVTEST_USE) --print=env) && PGO_NAMESPACE=" postgres-operator" QUERIES_CONFIG_DIR=" $( CURDIR) /${QUERIES_CONFIG_DIR} " \
212
215
$(GO_TEST ) -count=1 -cover ./...
@@ -299,20 +302,6 @@ generate-rbac: ## Generate RBAC
299
302
paths=' ./cmd/...' paths=' ./internal/...' \
300
303
output:dir=' config/rbac' # {directory}/role.yaml
301
304
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)
316
305
317
306
# #@ Release
318
307
0 commit comments