@@ -28,16 +28,10 @@ ALL_ARCH = amd64 arm64
28
28
TOOLS_DIR := hack/tools
29
29
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR ) /bin)
30
30
31
- GINKGO_VER := v1.16.5
32
- GINKGO_BIN := ginkgo
33
-
34
31
GINKGO_NODES ?= 3
35
32
GINKGO_NOCOLOR ?= false
36
33
GINKGO_ARGS ?=
37
- KUSTOMIZE_VER := v4.4.0
38
- KUSTOMIZE_BIN := kustomize
39
34
ROOT_DIR: =$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
40
- KUSTOMIZE := $(TOOLS_BIN_DIR ) /$(KUSTOMIZE_BIN ) -$(KUSTOMIZE_VER )
41
35
E2E_DATA_DIR ?= $(ROOT_DIR ) /test/e2e/data
42
36
OCI_TEMPLATES := $(E2E_DATA_DIR ) /infrastructure-oci
43
37
E2E_CONF_FILE ?= $(ROOT_DIR ) /test/e2e/config/e2e_conf.yaml
@@ -67,14 +61,24 @@ ENVSUBST_VER := v2.0.0-20210730161058-179042472c46
67
61
ENVSUBST_BIN := envsubst
68
62
ENVSUBST := $(TOOLS_BIN_DIR ) /$(ENVSUBST_BIN ) -$(ENVSUBST_VER )
69
63
70
- KUSTOMIZE_VER := v4.5.2
71
- KUSTOMIZE_BIN := kustomize
72
- KUSTOMIZE := $(TOOLS_BIN_DIR ) /$(KUSTOMIZE_BIN ) -$(KUSTOMIZE_VER )
73
-
74
64
KUBECTL_VER := v1.22.9
75
65
KUBECTL_BIN := kubectl
76
66
KUBECTL := $(TOOLS_BIN_DIR ) /$(KUBECTL_BIN ) -$(KUBECTL_VER )
77
67
68
+ BIN_DIR =$(shell pwd) /bin
69
+
70
+ KUSTOMIZE_BIN := kustomize
71
+ KUSTOMIZE := $(BIN_DIR ) /$(KUSTOMIZE_BIN )
72
+
73
+ GOLANGCI_LINT_BIN := golangci-lint
74
+ GOLANGCI_LINT := $(BIN_DIR ) /$(GOLANGCI_LINT_BIN )
75
+
76
+ GINKGO_BIN := ginkgo
77
+ GINKGO := $(BIN_DIR ) /$(GINKGO_BIN )
78
+
79
+ CONTROLLER_GEN_BIN = controller-gen
80
+ CONTROLLER_GEN := $(BIN_DIR ) /$(CONTROLLER_GEN_BIN )
81
+
78
82
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
79
83
ifeq (,$(shell go env GOBIN) )
80
84
GOBIN =$(shell go env GOPATH) /bin
@@ -108,14 +112,14 @@ help: ## Display this help.
108
112
109
113
# #@ Development
110
114
111
- manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
115
+ manifests : $( CONTROLLER_GEN ) # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
112
116
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) \
113
117
rbac:roleName=manager-role webhook \
114
118
paths=" ./api/..." \
115
119
paths=" ./exp/api/..." \
116
120
output:crd:artifacts:config=config/crd/bases
117
121
118
- generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
122
+ generate : $( CONTROLLER_GEN ) # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
119
123
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./api/..." paths=" ./exp/api/..."
120
124
121
125
fmt : # # Run go fmt against code.
@@ -143,7 +147,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
143
147
# # Linting
144
148
# # --------------------------------------
145
149
146
- lint : golangci-lint
150
+ lint : $( GOLANGCI_LINT )
147
151
$(GOLANGCI_LINT ) run -v --timeout 300s --fast=false
148
152
149
153
# # --------------------------------------
@@ -204,50 +208,19 @@ docker-push-manifest: ## Push the fat manifest docker image.
204
208
205
209
# #@ Deployment
206
210
207
- install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
211
+ install : manifests $( KUSTOMIZE ) # # Install CRDs into the K8s cluster specified in ~/.kube/config.
208
212
$(KUSTOMIZE ) build config/crd | kubectl apply -f -
209
213
210
- uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
214
+ uninstall : manifests $( KUSTOMIZE ) # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
211
215
$(KUSTOMIZE ) build config/crd | kubectl delete -f -
212
216
213
- deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
217
+ deploy : manifests $( KUSTOMIZE ) # # Deploy controller to the K8s cluster specified in ~/.kube/config.
214
218
cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
215
219
$(KUSTOMIZE ) build config/default | kubectl apply -f -
216
220
217
221
undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
218
222
$(KUSTOMIZE ) build config/default | kubectl delete -f -
219
223
220
-
221
- CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
222
- controller-gen : # # Download controller-gen locally if necessary.
223
- $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0)
224
-
225
- KUSTOMIZE = $(shell pwd) /bin/kustomize
226
- kustomize : # # Download kustomize locally if necessary.
227
- $(call go-get-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
228
-
229
- GINKGO := $(shell pwd) /bin/ginkgo
230
- ginkgo : # # Build ginkgo.
231
- $(call go-get-tool,$(GINKGO ) ,github.com/onsi/ginkgo/ginkgo@v1.16.5)
232
-
233
- GOLANGCI_LINT := $(shell pwd) /bin/golangci-lint
234
- golangci-lint : # # Build golanci-lint.
235
- $(call go-get-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.0)
236
-
237
- # go-get-tool will 'go get' any package $2 and install it to $1.
238
- PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
239
- define go-get-tool
240
- @[ -f $(1 ) ] || { \
241
- set -e ;\
242
- TMP_DIR=$$(mktemp -d ) ;\
243
- cd $$TMP_DIR ;\
244
- go mod init tmp ;\
245
- echo "Downloading $(2 ) " ;\
246
- GOBIN=$(PROJECT_DIR ) /bin go get $(2 ) ;\
247
- rm -rf $$TMP_DIR ;\
248
- }
249
- endef
250
-
251
224
MDBOOK = /tmp/mdbook
252
225
.PHONY : build-book
253
226
build-book : # # Download mdbook locally if necessary.
@@ -262,27 +235,27 @@ serve-book: build-book ## Build and serve the book with live-reloading enabled
262
235
# # --------------------------------------
263
236
264
237
.PHONY : generate-e2e-templates # # Generate OCI infrastructure templates for e2e test suite.
265
- generate-e2e-templates : kustomize
266
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template.yaml
267
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-alternative-region --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-alternative-region.yaml
268
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-bare-metal --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-bare-metal.yaml
269
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-md-remediation --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-md-remediation.yaml
270
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-kcp-remediation --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-kcp-remediation.yaml
271
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-node-drain --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-node-drain.yaml
272
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-antrea --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-antrea.yaml
273
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-oracle-linux --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-oracle-linux.yaml
274
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-seclist --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-seclist.yaml
275
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-nsg --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-nsg.yaml
276
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-multiple-node-nsg --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-multiple-node-nsg.yaml
277
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-cluster-class --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-cluster-class.yaml
278
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-local-vcn-peering --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-local-vcn-peering.yaml
279
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-remote-vcn-peering --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-remote-vcn-peering.yaml
280
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-externally-managed-vcn --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-externally-managed-vcn.yaml
281
- $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-machine-pool --load_restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-machine-pool.yaml
238
+ generate-e2e-templates : $( KUSTOMIZE )
239
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template.yaml
240
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-alternative-region --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-alternative-region.yaml
241
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-bare-metal --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-bare-metal.yaml
242
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-md-remediation --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-md-remediation.yaml
243
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-kcp-remediation --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-kcp-remediation.yaml
244
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-node-drain --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-node-drain.yaml
245
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-antrea --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-antrea.yaml
246
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-oracle-linux --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-oracle-linux.yaml
247
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-seclist --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-seclist.yaml
248
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-nsg --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-custom-networking-nsg.yaml
249
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-multiple-node-nsg --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-multiple-node-nsg.yaml
250
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-cluster-class --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-cluster-class.yaml
251
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-local-vcn-peering --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-local-vcn-peering.yaml
252
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-remote-vcn-peering --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-remote-vcn-peering.yaml
253
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-externally-managed-vcn --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-externally-managed-vcn.yaml
254
+ $(KUSTOMIZE ) build $(OCI_TEMPLATES ) /v1beta1/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES ) /v1beta1/cluster-template-machine-pool.yaml
282
255
283
256
.PHONY : test-e2e-run
284
- test-e2e-run : generate-e2e-templates ginkgo $(ENVSUBST ) # # Run e2e tests
285
- envsubst < $(E2E_CONF_FILE ) > $(E2E_CONF_FILE_ENVSUBST ) && \
257
+ test-e2e-run : generate-e2e-templates $( GINKGO ) $(ENVSUBST ) # # Run e2e tests
258
+ $( ENVSUBST ) < $(E2E_CONF_FILE ) > $(E2E_CONF_FILE_ENVSUBST ) && \
286
259
$(GINKGO) -v -trace -tags=e2e -focus="$(GINKGO_FOCUS)" -skip=$(GINKGO_SKIP) -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) ./test/e2e -- \
287
260
-e2e.artifacts-folder="$(ARTIFACTS)" \
288
261
-e2e.config="$(E2E_CONF_FILE_ENVSUBST)" \
@@ -327,7 +300,7 @@ release: clean-release ## Builds and push container images using the latest git
327
300
$(MAKE ) release-metadata
328
301
329
302
.PHONY : release-manifests
330
- release-manifests : kustomize $(RELEASE_DIR ) # # Builds the manifests to publish with a release
303
+ release-manifests : $( KUSTOMIZE ) $(RELEASE_DIR ) # # Builds the manifests to publish with a release
331
304
$(KUSTOMIZE ) build config/default > $(RELEASE_DIR ) /infrastructure-components.yaml
332
305
333
306
.PHONY : release-templates
@@ -350,15 +323,23 @@ GOARCH := $(shell go env GOARCH)
350
323
install-tools : $(ENVSUBST ) $(KUSTOMIZE ) $(KUBECTL )
351
324
352
325
envsubst : $(ENVSUBST ) # # Build a local copy of envsubst.
353
- kustomize : $(KUSTOMIZE ) # # Build a local copy of kustomize.
354
326
kubectl : $(KUBECTL ) # # Build a local copy of kubectl.
355
327
328
+ $(CONTROLLER_GEN ) : # # Download controller-gen locally if necessary.
329
+ GOBIN=$(BIN_DIR ) / $(GO_INSTALL ) sigs.k8s.io/controller-tools/cmd/controller-gen $(CONTROLLER_GEN_BIN ) v0.7.0
330
+
331
+ $(KUSTOMIZE ) : # # Download kustomize locally if necessary.
332
+ GOBIN=$(BIN_DIR ) / $(GO_INSTALL ) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN ) v4.5.2
333
+
334
+ $(GINKGO ) : # # Build ginkgo.
335
+ GOBIN=$(BIN_DIR ) / $(GO_INSTALL ) github.com/onsi/ginkgo/ginkgo $(GINKGO_BIN ) v1.16.5
336
+
337
+ $(GOLANGCI_LINT ) : # # Build golanci-lint.
338
+ GOBIN=$(BIN_DIR ) / $(GO_INSTALL ) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN ) v1.44.0
339
+
356
340
$(ENVSUBST ) : # # Build envsubst from tools folder.
357
341
GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) github.com/drone/envsubst/v2/cmd/envsubst $(ENVSUBST_BIN ) $(ENVSUBST_VER )
358
342
359
- $(KUSTOMIZE ) : # # Build kustomize from tools folder.
360
- GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN ) $(KUSTOMIZE_VER )
361
-
362
343
$(KUBECTL ) : # # Build kubectl from tools folder.
363
344
mkdir -p $(TOOLS_BIN_DIR )
364
345
rm -f " $( TOOLS_BIN_DIR) /$( KUBECTL_BIN) *"
0 commit comments