Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit af5a28b

Browse files
authored
Update test env Kube to lowest supported (#79)
1 parent 4451b5c commit af5a28b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Makefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ else
2424
GOBIN=$(shell go env GOBIN)
2525
endif
2626

27+
# KUBEBUILDER_ASSETS path is set as environment variable when running envtest.
28+
ENVTEST_BIN_VERSION = 1.21.4
29+
KUBEBUILDER_ASSETS = $(shell $(SETUP_ENVTEST) use -i -p path $(ENVTEST_BIN_VERSION))
30+
2731
# Setting SHELL to bash allows bash commands to be executed by recipes.
2832
# This is a requirement for 'setup-envtest.sh' in the test target.
2933
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
@@ -65,11 +69,9 @@ fmt: ## Run go fmt against code.
6569
vet: ## Run go vet against code.
6670
go vet ./...
6771

68-
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
69-
test: manifests generate fmt vet ## Run tests.
70-
mkdir -p ${ENVTEST_ASSETS_DIR}
71-
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
72-
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
72+
test: manifests generate fmt vet setup-envtest ## Run tests.
73+
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \
74+
go test ./... -coverprofile cover.out
7375

7476
update-kind-nodes:
7577
ifndef LATEST_KIND_NODE
@@ -120,7 +122,11 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
120122
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
121123
$(KUSTOMIZE) build config/default | kubectl delete -f -
122124

123-
125+
SETUP_ENVTEST = $(shell pwd)/bin/setup-envtest
126+
setup-envtest:
127+
$(call go-get-tool,$(SETUP_ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
128+
$(SETUP_ENVTEST) use $(ENVTEST_BIN_VERSION)
129+
124130
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
125131
controller-gen: ## Download controller-gen locally if necessary.
126132
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.0)

0 commit comments

Comments
 (0)