|
2 | 2 | # Image URL to use all building/pushing image targets |
3 | 3 | IMG ?= controller:latest |
4 | 4 | # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. |
5 | | -FLAGD_VERSION=v0.0.7 |
| 5 | +FLAGD_VERSION=v0.0.9 |
6 | 6 | ENVTEST_K8S_VERSION = 1.23 |
7 | 7 |
|
8 | 8 | # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) |
@@ -109,31 +109,34 @@ deploy: generate manifests kustomize ## Deploy controller to the K8s cluster spe |
109 | 109 | undeploy: generate ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. |
110 | 110 | $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - |
111 | 111 |
|
112 | | -CONTROLLER_GEN = $(shell pwd)/bin/controller-gen |
113 | | -.PHONY: controller-gen |
114 | | -controller-gen: ## Download controller-gen locally if necessary. |
115 | | - $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) |
| 112 | +##@ Build Dependencies |
| 113 | + |
| 114 | +## Location to install dependencies to |
| 115 | +LOCALBIN ?= $(shell pwd)/bin |
| 116 | +$(LOCALBIN): |
| 117 | + mkdir -p $(LOCALBIN) |
| 118 | + |
| 119 | +## Tool Binaries |
| 120 | +KUSTOMIZE ?= $(LOCALBIN)/kustomize |
| 121 | +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen |
| 122 | +ENVTEST ?= $(LOCALBIN)/setup-envtest |
116 | 123 |
|
117 | | -KUSTOMIZE = $(shell pwd)/bin/kustomize |
| 124 | +## Tool Versions |
| 125 | +KUSTOMIZE_VERSION ?= v4.5.7 |
| 126 | +CONTROLLER_TOOLS_VERSION ?= v0.8.0 |
| 127 | + |
| 128 | +KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" |
118 | 129 | .PHONY: kustomize |
119 | | -kustomize: ## Download kustomize locally if necessary. |
120 | | - $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) |
| 130 | +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. |
| 131 | +$(KUSTOMIZE): $(LOCALBIN) |
| 132 | + curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN) |
| 133 | + |
| 134 | +.PHONY: controller-gen |
| 135 | +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. |
| 136 | +$(CONTROLLER_GEN): $(LOCALBIN) |
| 137 | + GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) |
121 | 138 |
|
122 | | -ENVTEST = $(shell pwd)/bin/setup-envtest |
123 | 139 | .PHONY: envtest |
124 | | -envtest: ## Download envtest-setup locally if necessary. |
125 | | - $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) |
126 | | - |
127 | | -# go-get-tool will 'go get' any package $2 and install it to $1. |
128 | | -PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) |
129 | | -define go-get-tool |
130 | | -@[ -f $(1) ] || { \ |
131 | | -set -e ;\ |
132 | | -TMP_DIR=$$(mktemp -d) ;\ |
133 | | -cd $$TMP_DIR ;\ |
134 | | -go mod init tmp ;\ |
135 | | -echo "Downloading $(2)" ;\ |
136 | | -GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\ |
137 | | -rm -rf $$TMP_DIR ;\ |
138 | | -} |
139 | | -endef |
| 140 | +envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. |
| 141 | +$(ENVTEST): $(LOCALBIN) |
| 142 | + GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest |
0 commit comments