forked from kubernetes-sigs/cluster-api-provider-cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
468 lines (375 loc) · 18.9 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
467
468
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
export REPO_ROOT := $(shell git rev-parse --show-toplevel)
include $(REPO_ROOT)/common.mk
#
# Kubebuilder.
#
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.31.0
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?= 60s
export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?=
# Directories
TOOLS_DIR := $(REPO_ROOT)/hack/tools
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
BIN_DIR ?= bin
RELEASE_DIR ?= out
GO_INSTALL := ./hack/go_install.sh
GH_REPO ?= kubernetes-sigs/cluster-api-provider-cloudstack
# Helper function to get dependency version from go.mod
get_go_version = $(shell go list -m $1 | awk '{print $$2}')
# Set build time variables including version details
LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
# Binaries
KUSTOMIZE_VER := v5.3.0
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5
# This is a commit from CR main (22.05.2024).
# Intentionally using a commit from main to use a setup-envtest version
# that uses binaries from controller-tools, not GCS.
# CR PR: https://github.com/kubernetes-sigs/controller-runtime/pull/2811
SETUP_ENVTEST_VER := v0.0.0-20240522175850-2e9781e9fc60
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
CONTROLLER_GEN_VER := v0.15.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
GOTESTSUM_VER := v1.11.0
GOTESTSUM_BIN := gotestsum
GOTESTSUM := $(abspath $(TOOLS_BIN_DIR)/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER))
GOTESTSUM_PKG := gotest.tools/gotestsum
CONVERSION_GEN_VER := v0.30.0
CONVERSION_GEN_BIN := conversion-gen
# We are intentionally using the binary without version suffix, to avoid the version
# in generated files.
CONVERSION_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONVERSION_GEN_BIN))
CONVERSION_GEN_PKG := k8s.io/code-generator/cmd/conversion-gen
ENVSUBST_BIN := envsubst
ENVSUBST_VER := $(call get_go_version,github.com/drone/envsubst/v2)
ENVSUBST := $(abspath $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)-$(ENVSUBST_VER))
ENVSUBST_PKG := github.com/drone/envsubst/v2/cmd/envsubst
GO_APIDIFF_VER := v0.8.2
GO_APIDIFF_BIN := go-apidiff
GO_APIDIFF := $(abspath $(TOOLS_BIN_DIR)/$(GO_APIDIFF_BIN)-$(GO_APIDIFF_VER))
GO_APIDIFF_PKG := github.com/joelanford/go-apidiff
GINKGO_BIN := ginkgo
GINGKO_VER := $(call get_go_version,github.com/onsi/ginkgo/v2)
GINKGO := $(abspath $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINGKO_VER))
GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT_VER := v1.60.3
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
MOCKGEN_BIN := mockgen
MOCKGEN_VER := v1.6.0
MOCKGEN := $(abspath $(TOOLS_BIN_DIR)/$(MOCKGEN_BIN)-$(MOCKGEN_VER))
MOCKGEN_PKG := github.com/golang/mock/mockgen
KUBECTL := $(TOOLS_BIN_DIR)/kubectl
# Release
STAGING_REGISTRY := ghcr.io/leaseweb
STAGING_BUCKET ?= artifacts.k8s-staging-capi-cloudstack.appspot.com
BUCKET ?= $(STAGING_BUCKET)
PROD_REGISTRY ?= registry.k8s.io/capi-cloudstack
REGISTRY ?= $(STAGING_REGISTRY)
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
PULL_BASE_REF ?= $(RELEASE_TAG)
RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
# Image URL to use all building/pushing image targets
REGISTRY ?= $(STAGING_REGISTRY)
IMAGE_NAME ?= capi-cloudstack-controller
TAG ?= develop
CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME)
IMG ?= $(CONTROLLER_IMG):$(TAG)
IMG_LOCAL ?= localhost:5000/$(IMAGE_NAME):$(TAG)
MANIFEST_FILE := infrastructure-components
CONFIG_DIR := config
NAMESPACE := capc-system
# 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
# 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
export PATH := $(TOOLS_BIN_DIR):$(PATH)
all: build
##@ Binaries
## --------------------------------------
## Binaries
## --------------------------------------
.PHONY: binaries
binaries: $(CONTROLLER_GEN) $(CONVERSION_GEN) $(GOLANGCI_LINT) $(GINKGO) $(MOCKGEN) $(KUSTOMIZE) $(SETUP_ENVTEST) managers # Builds and installs all binaries
.PHONY: managers
managers:
$(MAKE) manager-cloudstack-infrastructure
.PHONY: manager-cloudstack-infrastructure
manager-cloudstack-infrastructure: ## Build manager binary.
CGO_ENABLED=0 go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
##@ Linting
## --------------------------------------
## Linting
## --------------------------------------
.PHONY: fmt
fmt: ## Run go fmt on the whole project.
go fmt ./...
.PHONY: vet
vet: ## Run go vet on the whole project.
go vet ./...
.PHONY: lint
lint: $(GOLANGCI_LINT) generate-mocks ## Run linting for the project.
$(MAKE) fmt
$(MAKE) vet
$(GOLANGCI_LINT) run -v --timeout 360s ./...
##@ Generate
## --------------------------------------
## Generate
## --------------------------------------
.PHONY: modules
modules: ## Runs go mod to ensure proper vendoring.
go mod tidy -compat=1.22
cd $(TOOLS_DIR); go mod tidy -compat=1.22
.PHONY: generate-all
generate-all: generate-mocks generate-conversion generate-deepcopy generate-manifests
.PHONY: generate-mocks
generate-mocks: $(MOCKGEN) generate-deepcopy pkg/mocks/mock_client.go $(shell find ./pkg/mocks -type f -name "mock*.go") ## Generate mocks needed for testing. Primarily mocks of the cloud package.
pkg/mocks/mock%.go: $(shell find ./pkg/cloud -type f -name "*test*" -prune -o -print)
go generate ./...
DEEPCOPY_GEN_TARGETS=$(shell find api -type d -name "v*" -exec echo {}\/zz_generated.deepcopy.go \;)
DEEPCOPY_GEN_INPUTS=$(shell find ./api -name "*test*" -prune -o -name "*zz_generated*" -prune -o -type f -print)
.PHONY: generate-deepcopy
generate-deepcopy: $(DEEPCOPY_GEN_TARGETS) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
api/%/zz_generated.deepcopy.go: $(CONTROLLER_GEN) $(DEEPCOPY_GEN_INPUTS)
CGO_ENABLED=0 $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
MANIFEST_GEN_INPUTS=$(shell find ./api ./controllers -type f -name "*test*" -prune -o -name "*zz_generated*" -prune -o -print)
# Using a flag file here as config output is too complicated to be a target.
# The following triggers manifest building if $(IMG) differs from that found in config/default/manager_image_patch.yaml.
$(shell grep -qs "$(IMG)" config/default/manager_image_patch_edited.yaml || rm -f config/.flag.mk)
.PHONY: generate-manifests
generate-manifests: config/.flag.mk ## Generates crd, webhook, rbac, and other configuration manifests from kubebuilder instructions in go comments.
config/.flag.mk: $(CONTROLLER_GEN) $(MANIFEST_GEN_INPUTS)
sed -e 's@image: .*@image: '"$(IMG)"'@' config/default/manager_image_patch.yaml > config/default/manager_image_patch_edited.yaml
$(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role webhook paths="{./,./api/...,./controllers/...}" output:crd:artifacts:config=config/crd/bases
@touch config/.flag.mk
.PHONY: generate-conversion
generate-conversion: $(CONVERSION_GEN) ## Generate code to convert api/v1beta1 and api/v1beta2 to api/v1beta3
$(CONVERSION_GEN) \
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate.go.txt \
./api/v1beta1
$(CONVERSION_GEN) \
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate.go.txt \
./api/v1beta2
##@ Build
## --------------------------------------
## Build
## --------------------------------------
MANAGER_BIN_INPUTS=$(shell find ./controllers ./api ./pkg -name "*mock*" -prune -o -name "*test*" -prune -o -type f -print) main.go go.mod go.sum
.PHONY: build
build: binaries generate-deepcopy generate-manifests release-manifests ## Build manager binary.
$(BIN_DIR)/manager: $(MANAGER_BIN_INPUTS)
go build -ldflags "${LDFLAGS}" -o $(BIN_DIR)/manager main.go
.PHONY: build-for-docker
build-for-docker: $(BIN_DIR)/manager-linux-amd64 ## Build manager binary for docker image building.
$(BIN_DIR)/manager-linux-amd64: $(MANAGER_BIN_INPUTS)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -a -ldflags "${LDFLAGS} -extldflags '-static'" \
-o $(BIN_DIR)/manager-linux-amd64 main.go
.PHONY: run
run: generate-deepcopy generate-conversion ## Run a controller from your host.
go run ./main.go
##@ Deploy
## --------------------------------------
## Deploy
## --------------------------------------
.PHONY: deploy
deploy: generate-deepcopy generate-manifests $(KUSTOMIZE) ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd $(REPO_ROOT)
$(KUSTOMIZE) build config/default | kubectl apply -f -
undeploy: $(KUSTOMIZE) ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -
##@ Docker
## --------------------------------------
## Docker
## --------------------------------------
# Using a flag file here as docker build doesn't produce a target file.
DOCKER_BUILD_INPUTS=$(MANAGER_BIN_INPUTS) Dockerfile
.PHONY: docker-build
docker-build: generate-deepcopy generate-conversion build-for-docker .dockerflag.mk ## Build docker image containing the controller manager.
.dockerflag.mk: $(DOCKER_BUILD_INPUTS)
docker build -t ${IMG} .
@touch .dockerflag.mk
.PHONY: docker-push
docker-push: .dockerflag.mk ## Push docker image with the manager.
docker push ${IMG}
##@ Tilt
## --------------------------------------
## Tilt Development
## --------------------------------------
.PHONY: tilt-up
tilt-up: cluster-api create-kind-cluster cluster-api/tilt-settings.json generate-manifests ## Setup and run tilt for development.
cd cluster-api && tilt up
KIND_CLUSTER_NAME := $(shell cat ./hack/tilt-settings.json | grep kind_cluster_name | cut -d: -f2 | xargs)
.PHONY: create-kind-cluster
create-kind-cluster: cluster-api cluster-api/tilt-settings.json ## Create a kind cluster with a local Docker repository.
@if [ -z "$$(kind get clusters | grep $(KIND_CLUSTER_NAME))" ]; then \
CAPI_KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) ./cluster-api/hack/kind-install-for-capd.sh; \
fi;
.PHONY: delete-kind-cluster
delete-kind-cluster:
kind delete cluster --name $(KIND_CLUSTER_NAME)
cluster-api: ## Clone cluster-api repository for tilt use.
git clone --branch v1.8.4 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
cp ./hack/tilt-settings.json cluster-api
##@ Tests
## --------------------------------------
## Tests
## --------------------------------------
KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))
DEEPCOPY_GEN_TARGETS_TEST=$(shell find test/fakes -type d -name "fakes" -exec echo {}\/zz_generated.deepcopy.go \;)
DEEPCOPY_GEN_INPUTS_TEST=$(shell find test/fakes/* -name "*zz_generated*" -prune -o -type f -print)
.PHONY: generate-deepcopy-test
generate-deepcopy-test: $(DEEPCOPY_GEN_TARGETS_TEST) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
test/fakes/zz_generated.deepcopy.go: $(CONTROLLER_GEN) $(DEEPCOPY_GEN_INPUTS_TEST)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
MANIFEST_GEN_INPUTS_TEST=$(shell find test/fakes/* -name "*zz_generated*" -prune -o -type f -print)
.PHONY: generate-manifest-test
generate-manifest-test: config/.flag-test.mk ## Generates crd, webhook, rbac, and other configuration manifests from kubebuilder instructions in go comments.
config/.flag-test.mk: $(CONTROLLER_GEN) $(MANIFEST_GEN_INPUTS_TEST)
$(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role webhook paths="./test/fakes" output:crd:artifacts:config=test/fakes
@touch config/.flag-test.mk
.PHONY: setup-envtest
setup-envtest: $(SETUP_ENVTEST) ## Set up envtest (download kubebuilder assets)
@echo KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)
.PHONY: test
test: ## Run tests.
test: generate-deepcopy-test generate-manifest-test generate-mocks setup-envtest $(GINKGO)
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GINKGO) --label-filter="!integ" --cover -coverprofile cover.out --covermode=atomic -v ./api/... ./controllers/... ./pkg/...
.PHONY: test-pkg
test-pkg: $(GINKGO) ## Run pkg tests.
@$(GINKGO) --label-filter="!integ" --cover -coverprofile cover.out --covermode=atomic -v ./pkg/...
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta*/cluster-template* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
CLUSTER_TEMPLATES_OUTPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack -type d -name "cluster-template*" -exec echo {}.yaml \;)
.PHONY: e2e-cluster-templates
e2e-cluster-templates: $(CLUSTER_TEMPLATES_OUTPUT_FILES) ## Generate cluster template files for e2e testing.
cluster-template%yaml: $(KUSTOMIZE) $(CLUSTER_TEMPLATES_INPUT_FILES)
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone $(basename $@) > $@
e2e-essentials: $(GINKGO) setup-envtest e2e-cluster-templates create-kind-cluster ## Fulfill essential tasks for e2e testing.
IMG=$(IMG_LOCAL) make generate-manifests docker-build docker-push
JOB ?= .*
E2E_CONFIG ?= ${REPO_ROOT}/test/e2e/config/cloudstack.yaml
run-e2e: e2e-essentials ## Run e2e testing. JOB is an optional REGEXP to select certainn test cases to run. e.g. JOB=PR-Blocking, JOB=Conformance
$(KUBECTL) apply -f cloud-config.yaml && \
cd test/e2e && \
$(GINKGO) -v --trace --tags=e2e --focus=$(JOB) --skip=Conformance --skip-package=kubeconfig_helper --nodes=1 --no-color=false ./... -- \
-e2e.artifacts-folder=${REPO_ROOT}/_artifacts \
-e2e.config=${E2E_CONFIG} \
-e2e.skip-resource-cleanup=false -e2e.use-existing-cluster=true
EXIT_STATUS=$$?
kind delete clusters capi-test
exit $$EXIT_STATUS
run-e2e-smoke:
./hack/ensure-kind.sh
./hack/ensure-cloud-config-yaml.sh
JOB="\"CAPC E2E SMOKE TEST\"" $(MAKE) run-e2e
##@ Cleanup
## --------------------------------------
## Cleanup
## --------------------------------------
.PHONY: clean
clean: ## Cleans up everything.
rm -rf $(RELEASE_DIR)
rm -rf bin
rm -rf $(TOOLS_BIN_DIR)
rm -rf cluster-api
rm -rf test/e2e/data/infrastructure-cloudstack/*/*yaml
rm -rf config/.flag.mk config/.flag-test.mk .dockerflag.mk
##@ Release
## --------------------------------------
## Release
## --------------------------------------
.PHONY: release-manifests
RELEASE_MANIFEST_TARGETS=$(RELEASE_DIR)/infrastructure-components.yaml $(RELEASE_DIR)/metadata.yaml
RELEASE_MANIFEST_INPUTS=$(KUSTOMIZE) config/.flag.mk $(shell find config)
RELEASE_MANIFEST_SOURCE_BASE ?= config/default
release-manifests: $(RELEASE_MANIFEST_TARGETS) ## Create kustomized release manifest in $RELEASE_DIR (defaults to out).
$(RELEASE_DIR)/%: $(RELEASE_MANIFEST_INPUTS)
@mkdir -p $(RELEASE_DIR)
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
$(KUSTOMIZE) build $(RELEASE_MANIFEST_SOURCE_BASE) > $(RELEASE_DIR)/infrastructure-components.yaml
.PHONY: release-manifests-metrics-port
release-manifests-metrics-port:
make release-manifests RELEASE_MANIFEST_SOURCE_BASE=config/default
.PHONY: release-staging
release-staging: ## Builds and push container images and manifests to the staging bucket.
$(MAKE) docker-build
$(MAKE) docker-push
$(MAKE) release-alias-tag
$(MAKE) release-templates
$(MAKE) release-manifests TAG=$(RELEASE_ALIAS_TAG)
$(MAKE) upload-staging-artifacts
.PHONY: release-alias-tag
release-alias-tag: # Adds the tag to the last build tag.
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
.PHONY: release-templates
release-templates: ## Generate release templates
@mkdir -p $(RELEASE_DIR)
cp templates/cluster-template*.yaml $(RELEASE_DIR)/
.PHONY: upload-staging-artifacts
upload-staging-artifacts: ## Upload release artifacts to the staging bucket
gsutil cp $(RELEASE_DIR)/* gs://$(STAGING_BUCKET)/components/$(RELEASE_ALIAS_TAG)/
##@ hack/tools:
.PHONY: $(CONTROLLER_GEN_BIN)
$(CONTROLLER_GEN_BIN): $(CONTROLLER_GEN) ## Build a local copy of controller-gen.
.PHONY: $(CONVERSION_GEN_BIN)
$(CONVERSION_GEN_BIN): $(CONVERSION_GEN) ## Build a local copy of conversion-gen.
.PHONY: $(ENVSUBST_BIN)
$(ENVSUBST_BIN): $(ENVSUBST) ## Build a local copy of envsubst.
.PHONY: $(KUSTOMIZE_BIN)
$(KUSTOMIZE_BIN): $(KUSTOMIZE) ## Build a local copy of kustomize.
.PHONY: $(SETUP_ENVTEST_BIN)
$(SETUP_ENVTEST_BIN): $(SETUP_ENVTEST) ## Build a local copy of setup-envtest.
.PHONY: $(GINKGO_BIN)
$(GINKGO_BIN): $(GINKGO) ## Build a local copy of ginkgo.
.PHONY: $(GOLANGCI_LINT_BIN)
$(GOLANGCI_LINT_BIN): $(GOLANGCI_LINT) ## Build a local copy of golangci-lint.
.PHONY: $(MOCKGEN_BIN)
$(MOCKGEN_BIN): $(MOCKGEN) ## Build a local copy of mockgen.
$(CONTROLLER_GEN): # Build controller-gen from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
## We are forcing a rebuilt of conversion-gen via PHONY so that we're always using an up-to-date version.
## We can't use a versioned name for the binary, because that would be reflected in generated files.
.PHONY: $(CONVERSION_GEN)
$(CONVERSION_GEN): # Build conversion-gen from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONVERSION_GEN_PKG) $(CONVERSION_GEN_BIN) $(CONVERSION_GEN_VER)
$(ENVSUBST): # Build gotestsum from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(ENVSUBST_PKG) $(ENVSUBST_BIN) $(ENVSUBST_VER)
$(KUSTOMIZE): # Build kustomize from tools folder.
CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)
$(SETUP_ENVTEST): # Build setup-envtest from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(SETUP_ENVTEST_PKG) $(SETUP_ENVTEST_BIN) $(SETUP_ENVTEST_VER)
$(GINKGO): # Build ginkgo from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GINKGO_PKG) $(GINKGO_BIN) $(GINGKO_VER)
$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
$(MOCKGEN): # Build mockgen from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(MOCKGEN_PKG) $(MOCKGEN_BIN) $(MOCKGEN_VER)