Skip to content

Commit

Permalink
Install setup-envtest utility if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavjainwiz committed Sep 5, 2023
1 parent 27ac6c9 commit 73c1b5a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ CONTROLLER_GEN_VERSION ?= "v0.11.4"
# https://github.com/kubernetes-sigs/controller-runtime/tree/main/tools/setup-envtest
# install with `go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest`
# find available versions by running `setup-envtest list`
KUBERNETES_VERSION ?= 1.23
KUBERNETES_VERSION ?= 1.26

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

ENVTEST ?= $(LOCALBIN)/setup-envtest
CRD_OPTIONS ?= "crd:maxDescLen=0"

# Model Mesh gRPC API Proto Generation
Expand All @@ -56,8 +62,8 @@ all: manager

.PHONY: test
## Run unit tests (Requires kubebuilder, etcd, kube-apiserver, envtest)
test:
KUBEBUILDER_ASSETS="$$(setup-envtest use $(KUBERNETES_VERSION) -p path)" \
test: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(KUBERNETES_VERSION) -p path)" \
KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT=120s \
go test -coverprofile cover.out `go list ./... | grep -v fvt`

Expand Down Expand Up @@ -212,5 +218,11 @@ check-doc-links:
help:
@perl -0 -nle 'printf("\033[36m %-20s\033[0m %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w.-]+):[^=]/gm' $(MAKEFILE_LIST) | sort

.PHONY: envtest
## Download envtest-setup locally if necessary.
envtest: $(ENVTEST)
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

# Override targets if they are included in RUN_ARGs so it doesn't run them twice
$(eval $(RUN_ARGS):;@:)

0 comments on commit 73c1b5a

Please sign in to comment.