-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
466 lines (363 loc) · 20.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# Image URL to use all building/pushing image targets
APISERVER_IMG ?= apiserver:latest
CONTROLLER_MANAGER_IMG ?= controller:latest
APINETLET_IMG ?= apinetlet:latest
METALNETLET_IMG ?= metalnetlet:latest
KIND_CLUSTER_NAME ?= kind
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.28.0
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
SSH_KEY ?= ${HOME}/.ssh/id_rsa
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
.PHONY: all
all: build
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: manifests
manifests: controller-gen ## Generate rbac objects.
# onmetal-api-net
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="./internal/controllers/..." output:rbac:artifacts:config=config/controller/rbac
# apinetlet
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="./apinetlet/controllers/..." output:rbac:artifacts:config=config/apinetlet/rbac
CONTROLLER_GEN=$(CONTROLLER_GEN) ./hack/cluster-controller-gen.sh cluster=apinet namespace=system rbac:roleName=apinet-role paths="./apinetlet/controllers/..." output:rbac:artifacts:config=config/apinetlet/apinet-rbac
# metalnetlet
CONTROLLER_GEN=$(CONTROLLER_GEN) ./hack/cluster-controller-gen.sh cluster=metalnet rbac:roleName=manager-role paths="./metalnetlet/controllers/..." output:rbac:artifacts:config=config/metalnetlet/rbac
$(CONTROLLER_GEN) rbac:roleName=apinet-role paths="./metalnetlet/controllers/..." output:rbac:artifacts:config=config/metalnetlet/apinet-rbac
# Promote *let roles.
./hack/promote-let-role.sh config/apinetlet/apinet-rbac/role.yaml config/apiserver/rbac/apinetlet_role.yaml apinet.api.onmetal.de:system:apinetlets
./hack/promote-let-role.sh config/metalnetlet/apinet-rbac/role.yaml config/apiserver/rbac/metalnetlet_role.yaml apinet.api.onmetal.de:system:metalnetlets
.PHONY: generate
generate: vgopath models-schema deepcopy-gen client-gen lister-gen informer-gen defaulter-gen conversion-gen openapi-gen applyconfiguration-gen
VGOPATH=$(VGOPATH) \
MODELS_SCHEMA=$(MODELS_SCHEMA) \
DEEPCOPY_GEN=$(DEEPCOPY_GEN) \
CLIENT_GEN=$(CLIENT_GEN) \
LISTER_GEN=$(LISTER_GEN) \
INFORMER_GEN=$(INFORMER_GEN) \
DEFAULTER_GEN=$(DEFAULTER_GEN) \
CONVERSION_GEN=$(CONVERSION_GEN) \
OPENAPI_GEN=$(OPENAPI_GEN) \
APPLYCONFIGURATION_GEN=$(APPLYCONFIGURATION_GEN) \
./hack/update-codegen.sh
.PHONY: add-license
add-license: addlicense ## Add license headers to all go files.
find . -name '*.go' -exec $(ADDLICENSE) -c 'OnMetal authors' {} +
.PHONY: fmt
fmt: goimports ## Run goimports against code.
$(GOIMPORTS) -w .
.PHONY: check-license
check-license: addlicense ## Check that every file has a license header present.
find . -name '*.go' -exec $(ADDLICENSE) -check -c 'OnMetal authors' {} +
.PHONY: lint
lint: ## Run golangci-lint against code.
golangci-lint run ./...
.PHONY: clean
clean: ## Clean any artifacts that can be regenerated.
rm -rf client-go/applyconfigurations
rm -rf client-go/informers
rm -rf client-go/listers
rm -rf client-go/onmetalapi
rm -rf client-go/openapi
.PHONY: check
check: generate manifests add-license fmt lint test ## Lint and run tests.
.PHONY: test
test: envtest generate fmt check-license test-only ## Run tests.
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
.PHONY: test-only
test-only: envtest ## Only run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
.PHONY: openapi-extractor
extract-openapi: envtest openapi-extractor
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(OPENAPI_EXTRACTOR) \
--apiserver-package="github.com/onmetal/onmetal-api-net/cmd/apiserver" \
--apiserver-build-opts=mod \
--apiservices="./config/apiserver/apiservice/bases" \
--output="./gen"
##@ Build
.PHONY: build-onmetal-api-net
build-onmetal-api-net: generate fmt addlicense lint ## Build onmetal-api-net binary.
go build -o bin/manager ./onmetal-api-net/main.go
.PHONY: build-apinetlet
build-apinetlet: generate fmt addlicense lint ## Build apinetlet.
go build -o bin/apinetlet ./apinetlet/main.go
.PHONY: build-metalnetlet
build-metalnetlet: generate fmt addlicense lint ## Build metalnetlet.
go build -o bin/metalnetlet ./metalnetlet/main.go
.PHONY: build
build: build-onmetal-api-net build-apinetlet build-metalnetlet ## Build onmetal-api-net, apinetlet, metalnetlet.
.PHONY: run-onmetal-api-net
run-onmetal-api-net: manifests generate fmt lint ## Run a onmetal-api-net from your host.
go run ./onmetal-api-net/main.go
.PHONY: run-apinetlet
run-apinetlet: manifests generate fmt lint ## Run apinetlet from your host.
go run ./apinetlet/main.go
.PHONY: run-metalnetlet
run-metalnetlet: manifests generate fmt lint ## Run metalnetlet from your host.
go run ./metalnetlet/main.go
.PHONY: docker-build-apiserver
docker-build-apiserver: ## Build apiserver image.
docker build --ssh default=${SSH_KEY} --target apiserver -t ${APISERVER_IMG} .
.PHONY: docker-build-controller-manager
docker-build-controller-manager: ## Build controller-manager image.
docker build --ssh default=${SSH_KEY} --target controller-manager -t ${CONTROLLER_MANAGER_IMG} .
.PHONY: docker-build-apinetlet
docker-build-apinetlet: ## Build apinetlet image with the manager.
docker build --ssh default=${SSH_KEY} --target apinetlet-manager -t ${APINETLET_IMG} .
.PHONY: docker-build-metalnetlet
docker-build-metalnetlet: ## Build metalnetlet image with the manager.
docker build --ssh default=${SSH_KEY} --target metalnetlet-manager -t ${METALNETLET_IMG} .
.PHONY: docker-build
docker-build: docker-build-apiserver docker-build-controller-manager docker-build-apinetlet docker-build-metalnetlet ## Build docker images.
.PHONY: docker-push-apiserver
docker-push-apiserver: ## Push apiserver image.
docker push ${APISERVER_IMG}
.PHONY: docker-push-controller-manager
docker-push-controller-manager: ## Push controller-manager image.
docker push ${CONTROLLER_MANAGER_IMG}
.PHONY: docker-push-apinetlet
docker-push-apinetlet: ## Push apinetlet image.
docker push ${APINETLET_IMG}
.PHONY: docker-push-metalnetlet
docker-push-metalnetlet: ## Push metalnetlet image.
docker push ${METALNETLET_IMG}
.PHONY: docker-push
docker-push: docker-push-apiserver docker-push-controller-manager docker-push-apinetlet docker-push-metalnetlet ## Push onmetal-api-net, apinetlet, metalnetlet image.
##@ Deployment
.PHONY: install-onmetal-api-net
install-onmetal-api-net: manifests ## Install onmetal-api-net CRDs into the K8s cluster specified in ~/.kube/config.
kubectl apply -k config/onmetal-api-net/crd
.PHONY: uninstall-onmetal-api-net
uninstall-onmetal-api-net: manifests ## Uninstall onmetal-api-net CRDs from the K8s cluster specified in ~/.kube/config.
kubectl delete-k config/onmetal-api-net/crd
.PHONY: install-apinetlet
install-apinetlet: manifests ## Install apinetlet CRDs into the K8s cluster specified in ~/.kube/config.
kubectl apply -k config/apinetlet/crd
.PHONY: uninstall-apinetlet
uninstall-apinetlet: manifests ## Uninstall apinetlet CRDs from the K8s cluster specified in ~/.kube/config.
kubectl delete-k config/apinetlet/crd
.PHONY: install-metalnetlet
install-metalnetlet: manifests ## Install metalnetlet CRDs into the K8s cluster specified in ~/.kube/config.
kubectl apply -k config/metalnetlet/crd
.PHONY: uninstall-metalnetlet
uninstall-metalnetlet: manifests ## Uninstall metalnetlet CRDs from the K8s cluster specified in ~/.kube/config.
kubectl delete-k config/metalnetlet/crd
.PHONY: install
install: install-onmetal-api-net install-apinetlet install-metalnetlet ## Uninstall onmetal-api-net, apinetlet, metalnetlet.
.PHONY: uninstall
uninstall: uninstall-onmetal-api-net uninstall-apinetlet uninstall-metalnetlet ## Uninstall onmetal-api-net, apinetlet, metalnetlet.
.PHONY: deploy-onmetal-api-net
deploy-onmetal-api-net: manifests kustomize ## Deploy onmetal-api-net controller to the K8s cluster specified in ~/.kube/config.
cd config/onmetal-api-net/manager && $(KUSTOMIZE) edit set image controller=${ONMETAL_API_NET_IMG}
kubectl apply -k config/onmetal-api-net/default
.PHONY: deploy-apinetlet
deploy-apinetlet: manifests kustomize ## Deploy apinetlet controller to the K8s cluster specified in ~/.kube/config.
cd config/apinetlet/manager && $(KUSTOMIZE) edit set image controller=${APINETLET_IMG}
kubectl apply -k config/apinetlet/default
.PHONY: deploy-metalnetlet
deploy-metalnetlet: manifests kustomize ## Deploy metalnetlet controller to the K8s cluster specified in ~/.kube/config.
cd config/metalnetlet/manager && $(KUSTOMIZE) edit set image controller=${METALNETLET_IMG}
kubectl apply -k config/metalnetlet/default
.PHONY: deploy
deploy: deploy-onmetal-api-net deploy-apinetlet deploy-metalnetlet ## Deploy onmetal-api-net, apinetlet, metalnetlet
.PHONY: undeploy-onmetal-api-net
undeploy-onmetal-api-net: ## Undeploy onmetal-api-net controller from the K8s cluster specified in ~/.kube/config.
kubectl delete -k config/onmetal-api-net
.PHONY: undeploy-apinetlet
undeploy-apinetlet: ## Undeploy apinetlet controller from the K8s cluster specified in ~/.kube/config.
kubectl delete -k config/apinetlet
.PHONY: undeploy-metalnetlet
undeploy-metalnetlet: ## Undeploy metalnetlet controller from the K8s cluster specified in ~/.kube/config.
kubectl delete -k config/metalnetlet
.PHONY: undeploy
undeploy: undeploy-onmetal-api-net undeploy-apinetlet undeploy-metalnetlet ## Undeploy onmetal-api-net, apinetlet, metalnetlet controller from the K8s cluster specified in ~/.kube/config.
##@ Kind Deployment plumbing
.PHONY: kind-load-apiserver
kind-load-apiserver: docker-build-apiserver ## Load apiserver image to kind cluster.
kind load docker-image --name ${KIND_CLUSTER_NAME} ${APISERVER_IMG}
.PHONY: kind-load-controller-manager
kind-load-controller-manager: docker-build-controller-manager ## Load controller-manager image to kind cluster.
kind load docker-image --name ${KIND_CLUSTER_NAME} ${CONTROLLER_MANAGER_IMG}
.PHONY: kind-load-apinetlet
kind-load-apinetlet: docker-build-apinetlet ## Load apinetlet image to kind cluster.
kind load docker-image --name ${KIND_CLUSTER_NAME} ${APINETLET_IMG}
.PHONY: kind-load-metalnetlet
kind-load-metalnetlet: docker-build-metalnetlet ## Load metalnetlet image to kind cluster.
kind load docker-image --name ${KIND_CLUSTER_NAME} ${METALNETLET_IMG}
.PHONY: kind-load
kind-load: kind-load-apiserver kind-load-controller-manager ## Load apiserver, controller-manager image to kind cluster.
.PHONY: kind-restart-apiserver
kind-restart-apiserver: ## Restarts the apiserver.
kubectl -n onmetal-api-net-system delete rs -l control-plane=apiserver
.PHONY: kind-restart-controller-manager
kind-restart-controller-manager: ## Restarts the controller-manager.
kubectl -n onmetal-api-net-system delete rs -l control-plane=controller-manager
.PHONY: kind-restart-apinetlet
kind-restart-apinetlet: ## Restarts the apinetlet controller manager.
kubectl -n apinetlet-system delete rs -l control-plane=controller-manager
.PHONY: kind-restart-metalnetlet
kind-restart-metalnetlet: ## Restarts the metalnetlet controller manager.
kubectl -n metalnetlet-system delete rs -l control-plane=controller-manager
.PHONY: kind-restart
kind-restart: kind-restart-apiserver kind-restart-controller-manager ## Restarts the apiserver, controller manager.
.PHONY: kind-build-load-restart-apiserver
kind-build-load-restart-apiserver: docker-build-apiserver kind-load-apiserver kind-restart-apiserver ## Build, load and restart apiserver.
.PHONY: kind-build-load-restart-controller-manager
kind-build-load-restart-controller-manager: docker-build-controller-manager kind-load-controller-manager kind-restart-controller-manager ## Build, load and restart controller-manager.
.PHONY: kind-build-load-restart-apinetlet
kind-build-load-restart-apinetlet: docker-build-apinetlet kind-load-apinetlet kind-restart-apinetlet ## Build, load and restart apinetlet.
.PHONY: kind-build-load-restart-metalnetlet
kind-build-load-restart-metalnetlet: docker-build-metalnetlet kind-load-metalnetlet kind-restart-metalnetlet ## Build, load and restart metalnetlet.
.PHONY: kind-build-load-restart
kind-build-load-restart: kind-build-load-restart-apiserver kind-build-load-restart-controller-manager
.PHONY: kind-apply-apinetlet
kind-apply-apinetlet: manifests ## Apply apinetlet to the cluster specified in ~/.kube/config.
kubectl apply -k config/apinetlet/kind
.PHONY: kind-apply-metalnetlet
kind-apply-metalnetlet: manifests ## Apply metalnetlet to the cluster specified in ~/.kube/config.
kubectl apply -k config/metalnetlet/kind
.PHONY: kind-apply
kind-apply: manifests ## Apply config/kind to the cluster specified in ~/.kube/config.
kubectl apply -k config/kind
.PHONY: kind-deploy
kind-deploy: kind-build-load-restart kind-apply ## Build, load and restart onmetal-api-net and apinetlet and apply them.
.PHONY: kind-delete
kind-delete: ## Delete config/kind from the cluster specified in ~/.kube/config.
kubectl delete -k config/kind
.PHONY: kind-delete-apinetlet
kind-delete-apinetlet: ## Delete apinetlet from the cluster specified in ~/.kube/config.
kubectl delete -k config/apinetlet/kind
.PHONY: kind-delete-metalnetlet
kind-delete-metalnetlet: ## Delete metalnetlet from the cluster specified in ~/.kube/config.
kubectl delete -k config/metalnetlet/kind
##@ Tools
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
OPENAPI_EXTRACTOR ?= $(LOCALBIN)/openapi-extractor
DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen
CLIENT_GEN ?= $(LOCALBIN)/client-gen
LISTER_GEN ?= $(LOCALBIN)/lister-gen
INFORMER_GEN ?= $(LOCALBIN)/informer-gen
DEFAULTER_GEN ?= $(LOCALBIN)/defaulter-gen
CONVERSION_GEN ?= $(LOCALBIN)/conversion-gen
OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen
APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen
VGOPATH ?= $(LOCALBIN)/vgopath
GEN_CRD_API_REFERENCE_DOCS ?= $(LOCALBIN)/gen-crd-api-reference-docs
ADDLICENSE ?= $(LOCALBIN)/addlicense
MODELS_SCHEMA ?= $(LOCALBIN)/models-schema
GOIMPORTS ?= $(LOCALBIN)/goimports
## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
CODE_GENERATOR_VERSION ?= v0.28.2
VGOPATH_VERSION ?= v0.1.1
CONTROLLER_TOOLS_VERSION ?= v0.13.0
GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0
ADDLICENSE_VERSION ?= v1.1.1
GOIMPORTS_VERSION ?= v0.13.0
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/kustomize; \
fi
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
.PHONY: deepcopy-gen
deepcopy-gen: $(DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary.
$(DEEPCOPY_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/deepcopy-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(CODE_GENERATOR_VERSION)
.PHONY: client-gen
client-gen: $(CLIENT_GEN) ## Download client-gen locally if necessary.
$(CLIENT_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODE_GENERATOR_VERSION)
.PHONY: lister-gen
lister-gen: $(LISTER_GEN) ## Download lister-gen locally if necessary.
$(LISTER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODE_GENERATOR_VERSION)
.PHONY: informer-gen
informer-gen: $(INFORMER_GEN) ## Download informer-gen locally if necessary.
$(INFORMER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODE_GENERATOR_VERSION)
.PHONY: defaulter-gen
defaulter-gen: $(DEFAULTER_GEN) ## Download defaulter-gen locally if necessary.
$(DEFAULTER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/defaulter-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/defaulter-gen@$(CODE_GENERATOR_VERSION)
.PHONY: conversion-gen
conversion-gen: $(CONVERSION_GEN) ## Download conversion-gen locally if necessary.
$(CONVERSION_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/conversion-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/conversion-gen@$(CODE_GENERATOR_VERSION)
.PHONY: openapi-gen
openapi-gen: $(OPENAPI_GEN) ## Download openapi-gen locally if necessary.
$(OPENAPI_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/openapi-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/openapi-gen@$(CODE_GENERATOR_VERSION)
.PHONY: applyconfiguration-gen
applyconfiguration-gen: $(APPLYCONFIGURATION_GEN) ## Download applyconfiguration-gen locally if necessary.
$(APPLYCONFIGURATION_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODE_GENERATOR_VERSION)
.PHONY: vgopath
vgopath: $(VGOPATH) ## Download vgopath locally if necessary.
.PHONY: $(VGOPATH)
$(VGOPATH): $(LOCALBIN)
@if test -x $(LOCALBIN)/vgopath && ! $(LOCALBIN)/vgopath version | grep -q $(VGOPATH_VERSION); then \
echo "$(LOCALBIN)/vgopath version is not expected $(VGOPATH_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/vgopath; \
fi
test -s $(LOCALBIN)/vgopath || GOBIN=$(LOCALBIN) go install github.com/onmetal/vgopath@$(VGOPATH_VERSION)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
.PHONY: openapi-extractor
openapi-extractor: $(OPENAPI_EXTRACTOR) ## Download openapi-extractor locally if necessary.
$(OPENAPI_EXTRACTOR): $(LOCALBIN)
test -s $(LOCALBIN)/openapi-extractor || GOBIN=$(LOCALBIN) go install github.com/onmetal/openapi-extractor/cmd/openapi-extractor@latest
.PHONY: gen-crd-api-reference-docs
gen-crd-api-reference-docs: $(GEN_CRD_API_REFERENCE_DOCS) ## Download gen-crd-api-reference-docs locally if necessary.
$(GEN_CRD_API_REFERENCE_DOCS): $(LOCALBIN)
test -s $(LOCALBIN)/gen-crd-api-reference-docs || GOBIN=$(LOCALBIN) go install github.com/ahmetb/gen-crd-api-reference-docs@$(GEN_CRD_API_REFERENCE_DOCS_VERSION)
.PHONY: addlicense
addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary.
$(ADDLICENSE): $(LOCALBIN)
test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION)
.PHONY: models-schema
models-schema: $(MODELS_SCHEMA) ## Install models-schema locally if necessary.
$(MODELS_SCHEMA): $(LOCALBIN)
test -s $(LOCALBIN)/models-schema || GOBIN=$(LOCALBIN) go install github.com/onmetal/onmetal-api-net/models-schema
.PHONY: goimports
goimports: $(GOIMPORTS) ## Download goimports locally if necessary.
$(GOIMPORTS): $(LOCALBIN)
test -s $(LOCALBIN)/goimports || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)