forked from vmware-tanzu/tanzu-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
511 lines (403 loc) · 20.7 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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# Copyright 2021 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
include ./common.mk
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
ifeq ($(GOHOSTOS), linux)
XDG_DATA_HOME := ${HOME}/.local/share
endif
ifeq ($(GOHOSTOS), darwin)
XDG_DATA_HOME := "$${HOME}/Library/Application Support"
endif
# Directories
TOOLS_DIR := $(abspath hack/tools)
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
BIN_DIR := bin
ROOT_DIR := $(shell git rev-parse --show-toplevel)
ADDONS_DIR := addons
UI_DIR := pkg/v1/tkg/web
# Add tooling binaries here and in hack/tools/Makefile
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports
GOBINDATA := $(TOOLS_BIN_DIR)/gobindata
KUBEBUILDER := $(TOOLS_BIN_DIR)/kubebuilder
YTT := $(TOOLS_BIN_DIR)/ytt
KUBEVAL := $(TOOLS_BIN_DIR)/kubeval
GINKGO := $(TOOLS_BIN_DIR)/ginkgo
VALE := $(TOOLS_BIN_DIR)/vale
TOOLING_BINARIES := $(GOLANGCI_LINT) $(YTT) $(KUBEVAL) $(GOIMPORTS) $(GOBINDATA) $(GINKGO) $(VALE)
PINNIPED_GIT_REPOSITORY = https://github.com/vmware-tanzu/pinniped.git
PINNIPED_VERSIONS = v0.4.4 v0.12.0
ifndef IS_OFFICIAL_BUILD
IS_OFFICIAL_BUILD = ""
endif
ifndef TANZU_PLUGIN_UNSTABLE_VERSIONS
TANZU_PLUGIN_UNSTABLE_VERSIONS = "experimental"
endif
# NPM registry to use for downloading node modules for UI build
CUSTOM_NPM_REGISTRY ?= $(shell git config tkg.npmregistry)
# TKG Compatibility Image repo and path related configuration
ifndef TKG_DEFAULT_IMAGE_REPOSITORY
TKG_DEFAULT_IMAGE_REPOSITORY = "projects-stg.registry.vmware.com/tkg"
endif
ifndef TKG_DEFAULT_COMPATIBILITY_IMAGE_PATH
# TODO change it to "tkg-compatibility" once the image is pushed to registry
TKG_DEFAULT_COMPATIBILITY_IMAGE_PATH = "framework-zshippable/tkg-compatibility"
endif
DOCKER_DIR := /app
SWAGGER=docker run --rm -v ${PWD}:${DOCKER_DIR} quay.io/goswagger/swagger:v0.21.0
# OCI registry for hosting tanzu framework components (containers and packages)
OCI_REGISTRY ?= projects.registry.vmware.com/tanzu_framework
# Add supported OS-ARCHITECTURE combinations here
ENVS := linux-amd64 windows-amd64 darwin-amd64
.DEFAULT_GOAL:=help
LD_FLAGS += -X 'main.BuildEdition=$(BUILD_EDITION)'
LD_FLAGS += -X 'github.com/vmware-tanzu/tanzu-framework/pkg/v1/buildinfo.IsOfficialBuild=$(IS_OFFICIAL_BUILD)'
ifneq ($(strip $(TANZU_CORE_BUCKET)),)
LD_FLAGS += -X 'github.com/vmware-tanzu/tanzu-framework/pkg/v1/config.CoreBucketName=$(TANZU_CORE_BUCKET)'
endif
ifeq ($(TANZU_FORCE_NO_INIT), true)
LD_FLAGS += -X 'github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli/command/core.forceNoInit=true'
endif
BUILD_TAGS ?=
ARTIFACTS_DIR ?= ./artifacts
XDG_CACHE_HOME := ${HOME}/.cache
export XDG_DATA_HOME
export XDG_CACHE_HOME
export OCI_REGISTRY
## --------------------------------------
## API/controller building and generation
## --------------------------------------
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
all: manager ui-build build-cli
manager: generate fmt vet ## Build manager binary
$(GO) build -ldflags "$(LD_FLAGS)" -o bin/manager main.go
run: generate fmt vet manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
$(GO) run -ldflags "$(LD_FLAGS)" ./main.go
install: manifests ## Install CRDs into a cluster
kustomize build config/crd | kubectl apply -f -
uninstall: manifests ## Uninstall CRDs from a cluster
kustomize build config/crd | kubectl delete -f -
deploy: manifests ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/default | kubectl apply -f -
manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
$(CRD_OPTIONS) \
paths=./apis/... \
output:crd:artifacts:config=config/crd/bases
generate-go: $(COUNTERFEITER) ## Generate code via go generate.
PATH=$(abspath hack/tools/bin):$(PATH) go generate ./...
generate: controller-gen ## Generate code via controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt",year=$(shell date +%Y) paths="./..."
$(MAKE) fmt
controller-gen: ## Download controller-gen
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
$(GO) mod init tmp ;\
$(GO) get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
## --------------------------------------
## Tooling Binaries
## --------------------------------------
tools: $(TOOLING_BINARIES) ## Build tooling binaries
.PHONY: $(TOOLING_BINARIES)
$(TOOLING_BINARIES):
make -C $(TOOLS_DIR) $(@F)
## --------------------------------------
## Version
## --------------------------------------
.PHONY: version
version: ## Show version
@echo $(BUILD_VERSION)
## --------------------------------------
## Build prerequisites
## --------------------------------------
.PHONY: ensure-pinniped-repo
ensure-pinniped-repo:
@rm -rf pinniped
@mkdir -p pinniped
@GIT_TERMINAL_PROMPT=0 git clone -q ${PINNIPED_GIT_REPOSITORY} pinniped > ${NUL} 2>&1
.PHONY: prep-build-cli
prep-build-cli: ensure-pinniped-repo
$(GO) mod download
$(GO) mod tidy
EMBED_PROVIDERS_TAG=embedproviders
ifeq "${BUILD_TAGS}" "${EMBED_PROVIDERS_TAG}"
make -C pkg/v1/providers -f Makefile generate-provider-bundle-zip
endif
.PHONY: configure-buildtags-%
configure-buildtags-%:
ifeq ($(strip $(BUILD_TAGS)),)
$(eval TAGS = $(word 1,$(subst -, ,$*)))
$(eval BUILD_TAGS=$(TAGS))
endif
@echo "BUILD_TAGS set to '$(BUILD_TAGS)'"
## --------------------------------------
## Build binaries and plugins
## --------------------------------------
# Dynamically generate the OS-ARCH targets to allow for parallel execution
CLI_JOBS := $(addprefix build-cli-,${ENVS})
CLI_ADMIN_JOBS := $(addprefix build-plugin-admin-,${ENVS})
RELEASE_JOBS := $(addprefix release-,${ENVS})
.PHONY: build-cli
build-cli: ${CLI_ADMIN_JOBS} ${CLI_JOBS} ## Build Tanzu CLI
@rm -rf pinniped
.PHONY: build-plugin-admin
build-plugin-admin: ${CLI_ADMIN_JOBS}
.PHONY: build-plugin-admin-%
build-plugin-admin-%:
$(eval ARCH = $(word 2,$(subst -, ,$*)))
$(eval OS = $(word 1,$(subst -, ,$*)))
@if [ "$(filter $(OS)-$(ARCH),$(ENVS))" = "" ]; then\
printf "\n\n======================================\n";\
printf "! $(OS)-$(ARCH) is not an officially supported platform!\n";\
printf "! Make sure to perform a full build to make sure expected plugins are available!\n";\
printf "======================================\n\n";\
fi
@echo build version: $(BUILD_VERSION)
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile --version $(BUILD_VERSION) --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --path ./cmd/cli/plugin-admin --artifacts artifacts-admin/${OS}/${ARCH}/cli --target ${OS}_${ARCH}
.PHONY: build-cli-%
build-cli-%: prep-build-cli
$(eval ARCH = $(word 2,$(subst -, ,$*)))
$(eval OS = $(word 1,$(subst -, ,$*)))
@if [ "$(filter $(OS)-$(ARCH),$(ENVS))" = "" ]; then\
printf "\n\n======================================\n";\
printf "! $(OS)-$(ARCH) is not an officially supported platform!\n";\
printf "! Make sure to perform a full build to make sure expected plugins are available!\n";\
printf "======================================\n\n";\
fi
./hack/embed-pinniped-binary.sh go ${OS} ${ARCH} ${PINNIPED_VERSIONS}
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile --version $(BUILD_VERSION) --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --corepath "cmd/cli/tanzu" --artifacts artifacts/${OS}/${ARCH}/cli --target ${OS}_${ARCH}
## --------------------------------------
## Build locally
## --------------------------------------
# By default `make build-cli-local` ensures that the cluster and management-cluster plugins are build
# with embedded provider templates. This is used only for dev build and not for production builds.
# When using embedded providers, `~/.config/tanzu/tkg/providers` directory always gets overwritten with the
# embdedded providers. To skip the provider updates, specify `SUPPRESS_PROVIDERS_UPDATE` environment variable.
# Note: If any local builds want to skip embedding providers and want utilize providers from TKG BoM file,
# To skip provider embedding, pass `BUILD_TAGS=skipembedproviders` to make target (`make BUILD_TAGS=skipembedproviders build-cli-local)
.PHONY: build-cli-local
build-cli-local: configure-buildtags-embedproviders build-cli-${GOHOSTOS}-${GOHOSTARCH} ## Build Tanzu CLI locally. cluster and management-cluster plugins are built with embedded providers.
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile --version $(BUILD_VERSION) --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --path ./cmd/cli/plugin-admin --artifacts artifacts-admin/${GOHOSTOS}/${GOHOSTARCH}/cli --target local
.PHONY: build-install-cli-local
build-install-cli-local: clean-catalog-cache clean-cli-plugins build-cli-local install-cli-plugins install-cli ## Local build and install the CLI plugins
## --------------------------------------
## manage cli mocks
## --------------------------------------
.PHONY: build-cli-mocks
build-cli-mocks: ## Build Tanzu CLI mocks
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile $(addprefix --target ,$(subst -,_,${ENVS})) --version 0.0.1 --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --path ./test/cli/mock/plugin-old --artifacts ./test/cli/mock/artifacts-old
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile $(addprefix --target ,$(subst -,_,${ENVS})) --version 0.0.2 --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --path ./test/cli/mock/plugin-new --artifacts ./test/cli/mock/artifacts-new
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile $(addprefix --target ,$(subst -,_,${ENVS})) --version 0.0.3 --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --path ./test/cli/mock/plugin-alt --artifacts ./test/cli/mock/artifacts-alt
## --------------------------------------
## install binaries and plugins
## --------------------------------------
.PHONY: install-cli
install-cli: ## Install Tanzu CLI
$(GO) install -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu
# Note: Invoking this target will update the unstableVersionSelector config
# file setting to 'experimental' by default. Use TANZU_PLUGIN_UNSTABLE_VERSIONS to
# override if necessary.
.PHONY: install-cli-plugins
install-cli-plugins: set-unstable-versions ## Install Tanzu CLI plugins
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go \
plugin install all --local $(ARTIFACTS_DIR)/$(GOHOSTOS)/$(GOHOSTARCH)/cli
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go \
plugin install all --local $(ARTIFACTS_DIR)-admin/$(GOHOSTOS)/$(GOHOSTARCH)/cli
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go \
test fetch --local $(ARTIFACTS_DIR)/$(GOHOSTOS)/$(GOHOSTARCH)/cli --local $(ARTIFACTS_DIR)-admin/$(GOHOSTOS)/$(GOHOSTARCH)/cli
.PHONY: set-unstable-versions
set-unstable-versions: ## Configures the unstable versions
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go config set unstable-versions $(TANZU_PLUGIN_UNSTABLE_VERSIONS)
.PHONY: build-install-cli-all ## Build and install the CLI plugins
build-install-cli-all: clean-catalog-cache clean-cli-plugins build-cli install-cli-plugins install-cli ## Build and install Tanzu CLI plugins
# This target is added as some tests still relies on tkg cli.
# TODO: Remove this target when all tests are migrated to use tanzu cli
.PHONY: tkg-cli ## Builds tkg-cli binary
tkg-cli: configure-buildtags-embedproviders configure-bom prep-build-cli ## Build tkg CLI binary only, and without rebuilding ui bits (providers are embedded to the binary)
GO111MODULE=on $(GO) build -o $(BIN_DIR)/tkg-${GOHOSTOS}-${GOHOSTARCH} -ldflags "${LD_FLAGS}" -tags "${BUILD_TAGS}" cmd/cli/tkg/main.go
.PHONY: build-cli-image
build-cli-image: ## Build the CLI image
docker build -t projects.registry.vmware.com/tanzu/cli:latest -f Dockerfile.cli .
## --------------------------------------
## Release binaries
## --------------------------------------
# TODO (pbarker): should work this logic into the builder plugin
.PHONY: release
release: ensure-pinniped-repo ${RELEASE_JOBS}
@rm -rf pinniped
.PHONY: release-%
release-%:
$(eval ARCH = $(word 2,$(subst -, ,$*)))
$(eval OS = $(word 1,$(subst -, ,$*)))
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile --version $(BUILD_VERSION) --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --path ./cmd/cli/plugin-admin --artifacts artifacts-admin/${OS}/${ARCH}/cli --target ${OS}_${ARCH}
./hack/embed-pinniped-binary.sh go ${OS} ${ARCH} ${PINNIPED_VERSIONS}
$(GO) run ./cmd/cli/plugin-admin/builder/main.go cli compile --version $(BUILD_VERSION) --ldflags "$(LD_FLAGS)" --tags "${BUILD_TAGS}" --corepath "cmd/cli/tanzu" --artifacts artifacts/${OS}/${ARCH}/cli --target ${OS}_${ARCH}
## --------------------------------------
## Testing, verification, formating and cleanup
## --------------------------------------
.PHONY: test
test: generate fmt vet manifests build-cli-mocks ## Run tests
## Skip running TKG integration tests
$(MAKE) ytt -C $(TOOLS_DIR)
PATH=$(abspath hack/tools/bin):$(PATH) $(GO) test -coverprofile cover.out -v `go list ./... | grep -v github.com/vmware-tanzu/tanzu-framework/pkg/v1/tkg/test`
$(MAKE) kubebuilder -C $(TOOLS_DIR)
KUBEBUILDER_ASSETS=$(ROOT_DIR)/$(KUBEBUILDER)/bin $(MAKE) test -C addons
.PHONY: test-cli
test-cli: build-cli-mocks ## Run tests
$(GO) test ./...
fmt: tools ## Run goimports
$(GOIMPORTS) -w -local github.com/vmware-tanzu ./
vet: ## Run go vet
$(GO) vet ./...
lint: tools doc-lint ## Run linting checks
# Linter runs per module, add each one here and make sure they match
# in .github/workflows/main.yaml for CI coverage
$(GOLANGCI_LINT) run -v
cd $(ADDONS_DIR); $(GOLANGCI_LINT) run -v
cd $(ADDONS_DIR)/pinniped/post-deploy/; $(GOLANGCI_LINT) run -v
# Check licenses in shell scripts and Makefile
hack/check-license.sh
doc-lint: tools ## Run linting checks for docs
$(VALE) --config=.vale/config.ini --glob='*.md' ./
# mdlint rules with possible errors and fixes can be found here:
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
# Additional configuration can be found in the .markdownlintrc file.
hack/check-mdlint.sh
.PHONY: modules
modules: ## Runs go mod to ensure modules are up to date.
$(GO) mod tidy
cd $(ADDONS_DIR); $(GO) mod tidy
cd $(ADDONS_DIR)/pinniped/post-deploy/; $(GO) mod tidy
cd $(TOOLS_DIR); $(GO) mod tidy
.PHONY: verify
verify: ## Run all verification scripts
./hack/verify-dirty.sh
.PHONY: clean-catalog-cache
clean-catalog-cache: ## Cleans catalog cache
@rm -rf ${XDG_CACHE_HOME}/tanzu/*
.PHONY: clean-cli-plugins
clean-cli-plugins: ## Remove Tanzu CLI plugins
- rm -rf ${XDG_DATA_HOME}/tanzu-cli/*
## --------------------------------------
## UI Build & Test
## --------------------------------------
.PHONY: update-npm-registry
update-npm-registry: ## set alternate npm registry
ifneq ($(strip $(CUSTOM_NPM_REGISTRY)),)
npm config set registry $(CUSTOM_NPM_REGISTRY) web
endif
.PHONY: ui-dependencies
ui-dependencies: update-npm-registry ## install UI dependencies (node modules)
cd $(UI_DIR); NG_CLI_ANALYTICS=ci npm ci; cd ../
.PHONY: ui-build
ui-build: ui-dependencies ## install dependencies, then compile client UI for production
cd $(UI_DIR); npm run build:prod; cd ../
$(MAKE) generate-ui-bindata
.PHONY: ui-build-and-test
ui-build-and-test: ui-dependencies ## compile client UI for production and run tests
cd $(UI_DIR); npm run build:ci; cd ../
$(MAKE) generate-ui-bindata
.PHONY: verify-ui-bindata
verify-ui-bindata: ## Run verification for ui bindata
git diff --exit-code pkg/v1/tkg/manifest/server/zz_generated.bindata.go
## --------------------------------------
## Generate files
## --------------------------------------
.PHONY: cobra-docs
cobra-docs:
TANZU_CLI_NO_INIT=true TANZU_CLI_NO_COLOR=true $(GO) run ./cmd/cli/tanzu generate-all-docs
sed -i.bak -E 's/\/[A-Za-z]*\/([a-z]*)\/.config\/tanzu\/pinniped\/sessions.yaml/~\/.config\/tanzu\/pinniped\/sessions.yaml/g' docs/cli/commands/tanzu_pinniped-auth_login.md
.PHONY: generate-fakes
generate-fakes: ## Generate fakes for writing unit tests
$(GO) generate ./...
$(MAKE) fmt
.PHONY: generate-ui-bindata
generate-ui-bindata: $(GOBINDATA) ## Generate go-bindata for ui files
$(GOBINDATA) -mode=420 -modtime=1 -o=pkg/v1/tkg/manifest/server/zz_generated.bindata.go -pkg=server $(UI_DIR)/dist/...
$(MAKE) fmt
.PHONY: generate-telemetry-bindata
generate-telemetry-bindata: $(GOBINDATA) ## Generate telemetry bindata
$(GOBINDATA) -mode=420 -modtime=1 -o=pkg/v1/tkg/manifest/telemetry/zz_generated.bindata.go -pkg=telemetry pkg/v1/tkg/manifest/telemetry/...
$(MAKE) fmt
# TODO: Remove bindata dependency and use go embed
.PHONY: generate-bindata ## Generate go-bindata files
generate-bindata: generate-telemetry-bindata generate-ui-bindata
.PHONY: configure-bom
configure-bom:
# Update default BoM Filename variable in tkgconfig pkg
sed "s+TKG_DEFAULT_IMAGE_REPOSITORY+${TKG_DEFAULT_IMAGE_REPOSITORY}+g" hack/update-bundled-bom-filename/update-bundled-default-bom-files-configdata.txt | \
sed "s+TKG_DEFAULT_COMPATIBILITY_IMAGE_PATH+${TKG_DEFAULT_COMPATIBILITY_IMAGE_PATH}+g" | \
sed "s+TKG_MANAGEMENT_CLUSTER_PLUGIN_VERSION+${BUILD_VERSION}+g" > pkg/v1/tkg/tkgconfigpaths/zz_bundled_default_bom_files_configdata.go
.PHONY: generate-ui-swagger-api
generate-ui-swagger-api: ## Generate swagger files for UI backend
rm -rf ${UI_DIR}/server/client ${UI_DIR}/server/models ${UI_DIR}/server/restapi/operations
${SWAGGER} generate server -q -A kickstartUI -t $(DOCKER_DIR)/${UI_DIR}/server -f $(DOCKER_DIR)/${UI_DIR}/api/spec.yaml --exclude-main
${SWAGGER} generate client -q -A kickstartUI -t $(DOCKER_DIR)/${UI_DIR}/server -f $(DOCKER_DIR)/${UI_DIR}/api/spec.yaml
# reset the server.go file to avoid goswagger overwritting our custom changes.
git reset HEAD ${UI_DIR}/server/restapi/server.go
git checkout HEAD ${UI_DIR}/server/restapi/server.go
$(MAKE) fmt
## --------------------------------------
## Provider templates/overlays
## --------------------------------------
.PHONY: clustergen
clustergen:
CLUSTERGEN_BASE=${CLUSTERGEN_BASE} make -C pkg/v1/providers -f Makefile cluster-generation-diffs
.PHONY: generate-embedproviders
generate-embedproviders:
make -C pkg/v1/providers -f Makefile generate-provider-bundle-zip
## --------------------------------------
## TKG integration tests
## --------------------------------------
GINKGO_NODES ?= 1
GINKGO_NOCOLOR ?= false
.PHONY: e2e-tkgctl-docker
e2e-tkgctl-docker: $(GINKGO) generate-embedproviders ## Run ginkgo tkgctl E2E tests
$(GINKGO) -v -trace -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) -tags embedproviders pkg/v1/tkg/test/tkgctl/docker
.PHONY: e2e-tkgctl-azure
e2e-tkgctl-azure: $(GINKGO) generate-embedproviders ## Run ginkgo tkgctl E2E tests
$(GINKGO) -v -trace -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) -tags embedproviders pkg/v1/tkg/test/tkgctl/azure
.PHONY: e2e-tkgctl-aws
e2e-tkgctl-aws: $(GINKGO) generate-embedproviders ## Run ginkgo tkgctl E2E tests
$(GINKGO) -v -trace -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) -tags embedproviders pkg/v1/tkg/test/tkgctl/aws
.PHONY: e2e-tkgctl-vc67
e2e-tkgctl-vc67: $(GINKGO) generate-embedproviders ## Run ginkgo tkgctl E2E tests
$(GINKGO) -v -trace -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) -tags embedproviders pkg/v1/tkg/test/tkgctl/vsphere67
.PHONY: e2e-tkgpackageclient-docker
e2e-tkgpackageclient-docker: $(GINKGO) generate-embedproviders ## Run ginkgo tkgpackageclient E2E tests
$(GINKGO) -v -trace -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) -tags embedproviders pkg/v1/tkg/test/tkgpackageclient
## --------------------------------------
## Docker build
## --------------------------------------
# These are the components in this repo that need to have a docker image built.
# This variable refers to directory paths that contain a Makefile with `docker-build`, `docker-publish` and
# `kbld-image-replace` targets that can build and push a docker image for that component.
COMPONENTS := pkg/v1/sdk/features
.PHONY: docker-build
docker-build: TARGET=docker-build
docker-build: $(COMPONENTS)
.PHONY: docker-publish
docker-publish: TARGET=docker-publish
docker-publish: $(COMPONENTS)
.PHONY: kbld-image-replace
kbld-image-replace: TARGET=kbld-image-replace
kbld-image-replace: $(COMPONENTS)
.PHONY: $(COMPONENTS)
$(COMPONENTS):
$(MAKE) -C $@ $(TARGET) IMG_VERSION_OVERRIDE=$(BUILD_VERSION)
.PHONY: docker-all
docker-all: docker-build docker-publish kbld-image-replace