forked from meshery/kubectl-kanvas-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
453 lines (385 loc) · 16.1 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
# Copyright Meshery 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.
include install/Makefile.core.mk
include install/Makefile.show-help.mk
#-----------------------------------------------------------------------------
# Docker-based Builds
#-----------------------------------------------------------------------------
.PHONY: docker-build docker-local-cloud docker-cloud docker-playground-build docker-testing-env-build docker-testing-env
## Build Meshery Server and UI container.
docker-build:
# `make docker-build` builds Meshery inside of a multi-stage Docker container.
# This method does NOT require that you have Go, NPM, etc. installed locally.
DOCKER_BUILDKIT=1 docker build -f install/docker/Dockerfile -t layer5/meshery --build-arg TOKEN=$(GLOBAL_TOKEN) --build-arg GIT_COMMITSHA=$(GIT_COMMITSHA) --build-arg GIT_VERSION=$(GIT_VERSION) --build-arg RELEASE_CHANNEL=${RELEASE_CHANNEL} .
## Build Meshery Server and UI container in Playground mode.
docker-playground-build:
# `make docker-playground-build` builds Meshery inside of a multi-stage Docker container.
# This method does NOT require that you have Go, NPM, etc. installed locally.
DOCKER_BUILDKIT=1 docker build -f install/docker/Dockerfile -t layer5/meshery --build-arg TOKEN=$(GLOBAL_TOKEN) --build-arg GIT_COMMITSHA=$(GIT_COMMITSHA) --build-arg GIT_VERSION=$(GIT_VERSION) --build-arg RELEASE_CHANNEL=${RELEASE_CHANNEL} --build-arg PROVIDER=$(LOCAL_PROVIDER) --build-arg PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) --build-arg PLAYGROUND=true .
## Build Meshery Server and UI container for e2e testing.
docker-testing-env-build:
# `make docker-build` builds Meshery inside of a multi-stage Docker container.
# This method does NOT require that you have Go, NPM, etc. installed locally.
DOCKER_BUILDKIT=1 docker build -f install/docker/testing/Dockerfile -t layer5/meshery-testing-env --build-arg GIT_VERSION=$(GIT_VERSION) .
## Meshery Cloud for user authentication.
## Runs Meshery in a container locally and points to locally-running
docker-local-cloud:
(docker rm -f meshery) || true
docker run --name meshery -d \
--link meshery-cloud:meshery-cloud \
-e PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_LOCAL) \
-e DEBUG=true \
-e ADAPTER_URLS=$(ADAPTER_URLS) \
-e KEYS_PATH=$(KEYS_PATH) \
-p 9081:8080 \
layer5/meshery ./meshery
## Runs Meshery in a container locally and points to remote
## Remote Provider for user authentication.
docker-cloud:
(docker rm -f meshery) || true
docker run --name meshery -d \
-e PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
-e DEBUG=true \
-e ADAPTER_URLS=$(ADAPTER_URLS) \
-e KEYS_PATH=$(KEYS_PATH) \
-v meshery-config:/home/appuser/.meshery/config \
-v $(HOME)/.kube:/home/appuser/.kube:ro \
-p 9081:8080 \
layer5/meshery ./meshery
## Runs Meshery in a container locally and points to remote
## Remote Provider for user authentication.
docker-testing-env:
docker run --rm --name mesherytesting -d \
-e PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
-e DEBUG=true \
-e ADAPTER_URLS=$(ADAPTER_URLS) \
-e KEYS_PATH=$(KEYS_PATH) \
-v meshery-config:/home/appuser/.meshery/config \
-v $(HOME)/.kube:/home/appuser/.kube:ro \
-p 9081:8080 \
layer5/meshery-testing-env ./meshery
#-----------------------------------------------------------------------------
# Meshery Server Native Builds
#-----------------------------------------------------------------------------
.PHONY: server wrk2-setup nighthawk-setup server-local server-skip-compgen server-no-content golangci proto-build error build-server server-binary
## Setup wrk2 for local development.
wrk2-setup:
echo "setup-wrk does not work on Mac Catalina at the moment"
cd server; cd cmd; git clone https://github.com/layer5io/wrk2.git; cd wrk2; make; cd ..
## Setup nighthawk for local development.
nighthawk-setup: dep-check
cd server; cd cmd; git clone https://github.com/layer5io/nighthawk-go.git; cd nighthawk-go; make setup; cd ..
run-local: server-local error
## Build and run Meshery Server on your local machine
## and point to (expect) a locally running Remote Provider
## for user authentication.
server-local: dep-check
cd server; cd cmd; go clean; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_LOCAL) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go
## Build Meshery Server on your local machine.
build-server: dep-check
cd server; cd cmd; go mod tidy; cd "../.."
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
GOPROXY=https://proxy.golang.org,direct GO111MODULE=on go build ./server/cmd/main.go ./server/cmd/error.go
chmod +x ./main
## Running the meshery server using binary.
server-binary:
cd server/cmd; BUILD="$(GIT_VERSION)" PROVIDER_BASE_URLS=$(MESHERY_CLOUD_STAGING) ../../main; cd ../../
## Build and run Meshery Server on your local machine
## and point to Remote Provider in staging environment
server-stg: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_STAGING) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server on your local machine.
server: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server with some Meshery Adapters on your local machine.
server-with-adapters: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server on your local machine.
## Disable deployment of the Meshery Operator to your Kubernetes cluster(s).
server-without-operator: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DISABLE_OPERATOR=true \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server with no Kubernetes components on your local machine.
server-skip-compgen:
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
SKIP_COMP_GEN=true \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server on your local machine.
## Do not generate and register Kubernetes models.
server-without-k8s: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
REGISTER_STATIC_K8S=false \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
server-remote-provider: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER=$(REMOTE_PROVIDER) \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
server-local-provider: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER=$(LOCAL_PROVIDER) \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_DEV) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server with no seed content.
server-no-content:
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
SKIP_DOWNLOAD_CONTENT=true \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
server-playground: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER=$(REMOTE_PROVIDER) \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_PROD) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
PLAYGROUND=true \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Lint check Meshery Server.
golangci: error dep-check
golangci-lint run
## Build Meshery's protobufs.
proto-build:
# see https://developers.google.com/protocol-buffers/docs/reference/go-generated
# see https://grpc.io/docs/languages/go/quickstart/
export PATH=$(PATH):$(GOBIN)
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
protoc --proto_path=server/meshes --go_out=server/meshes --go_opt=paths=source_relative --go-grpc_out=server/meshes --go-grpc_opt=paths=source_relative meshops.proto
## Analyze error codes
error: dep-check
go run github.com/layer5io/meshkit/cmd/errorutil -d . analyze -i ./server/helpers -o ./server/helpers --skip-dirs mesheryctl
## Runs meshkit error utility to update error codes for meshery server only.
error-util:
go run github.com/layer5io/meshkit/cmd/errorutil -d . --skip-dirs mesheryctl update -i ./server/helpers/ -o ./server/helpers
## Build Meshery UI; Build and run Meshery Server on your local machine.
ui-server: ui-meshery-build ui-provider-build server
#-----------------------------------------------------------------------------
# Meshery UI Native Builds.
#-----------------------------------------------------------------------------
.PHONY: ui-setup ui ui-meshery-build ui-provider ui-lint ui-provider ui-meshery ui-build ui-provider-build ui-provider-test
UI_BUILD_SCRIPT = build16
UI_DEV_SCRIPT = dev16
ifeq ($(findstring v19, $(shell node --version)), v19)
UI_BUILD_SCRIPT = build
UI_DEV_SCRIPT = dev
else ifeq ($(findstring v18, $(shell node --version)), v18)
UI_BUILD_SCRIPT = build
UI_DEV_SCRIPT = dev
else ifeq ($(findstring v17, $(shell node --version)), v17)
UI_BUILD_SCRIPT = build
UI_DEV_SCRIPT = dev
endif
## Install dependencies for building Meshery UI.
ui-setup:
cd ui; npm i; cd ..
cd provider-ui; npm i; cd ..
## Run Meshery UI on your local machine. Listen for changes.
ui:
cd ui; npm run dev; cd ..;
## Run Meshery Provider UI on your local machine. Listen for changes.
ui-provider:
cd provider-ui; npm run dev; cd ..
## Lint check Meshery UI and Provider UI on your local machine.
ui-lint:
cd ui; npm run lint; cd ..
## Lint check Meshery Provider UI on your local machine.
ui-provider-lint:
cd provider-ui; npm run lint; cd ..
## Test Meshery Provider UI on your local machine.
ui-provider-test:
cd provider-ui; npm run test; cd ..
## Buils all Meshery UIs on your local machine.
ui-build: ui-setup
cd ui; npm run lint:fix && npm run build && npm run export; cd ..
cd provider-ui; npm run lint:fix && npm run build && npm run export; cd ..
## Build only Meshery UI on your local machine.
ui-meshery-build:
cd ui; npm run build && npm run export; cd ..
## Builds only the provider user interface on your local machine
ui-provider-build:
cd provider-ui; npm run build && npm run export; cd ..
## Run Meshery End-to-End Integration Tests against your local Meshery UI (runs in non-interactive mode).
ui-integration-tests: ui-setup
cd ui; npm run ci-test-integration; cd ..
#-----------------------------------------------------------------------------
# Meshery Docs
#-----------------------------------------------------------------------------
#Incorporating Make docs commands from the Docs Makefile
.PHONY: docs docs-build site docs-docker docs-mesheryctl
jekyll=bundle exec jekyll
site: docs
site-serve: docs-serve
## Run Meshery Docs. Listen for changes.
docs:
cd docs; bundle install; bundle exec jekyll serve --drafts --incremental --config _config_dev.yml
## Run Meshery Docs. Do not listen for changes.
docs-serve:
cd docs; bundle install; bundle exec jekyll serve --drafts --config _config_dev.yml
## Build Meshery Docs on your local machine.
docs-build:
cd docs; $(jekyll) build --drafts
## Run Meshery Docs in a Docker container. Listen for changes.
docs-docker:
cd docs; docker run --name meshery-docs --rm -p 4000:4000 -v `pwd`:"/srv/jekyll" jekyll/jekyll:4.0 bash -c "bundle install; jekyll serve --drafts --livereload"
## Build Meshery CLI docs
docs-mesheryctl:
cd mesheryctl; make docs;
#-----------------------------------------------------------------------------
# Meshery Helm Charts
#-----------------------------------------------------------------------------
.PHONY: helm-docs helm-operator-docs helm-meshery-docs helm-operator-lint helm-lint
## Generate all Meshery Helm Chart documentation in markdown format.
helm-docs: helm-operator-docs helm-meshery-docs
## Generate Meshery Operator Helm Chart documentation in markdown format.
helm-operator-docs: dep-check
GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
$(GOPATH)/bin/helm-docs -c install/kubernetes/helm/meshery-operator
## Generate Meshery Server and Adapters Helm Chart documentation in markdown format.
helm-meshery-docs: dep-check
GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
$(GOPATH)/bin/helm-docs -c install/kubernetes/helm/meshery
## Lint all of Meshery's Helm Charts
helm-lint: helm-operator-lint helm-meshery-lint
## Lint Meshery Operator Helm Chart
helm-operator-lint:
helm lint install/kubernetes/helm/meshery-operator --with-subcharts
## Lint Meshery Server and Adapter Helm Charts
helm-meshery-lint:
helm lint install/kubernetes/helm/meshery --with-subcharts
#-----------------------------------------------------------------------------
# Meshery APIs
#-----------------------------------------------------------------------------
.PHONY: swagger-build swagger swagger-docs-build graphql-docs-build graphql-build
## Build Meshery REST API specifications
swagger-build:
swagger generate spec -o ./server/helpers/swagger.yaml --scan-models
## Generate and serve Meshery REST API specifications
swagger: swagger-build
swagger serve ./server/helpers/swagger.yaml
## Build Meshery REST API documentation
swagger-docs-build:
swagger generate spec -o ./docs/_data/swagger.yml --scan-models; \
swagger flatten ./docs/_data/swagger.yml -o ./docs/_data/swagger.yml --with-expand --format=yaml
## Building Meshery docs with redocly
redocly-docs-build:
npx @redocly/cli build-docs ./docs/_data/swagger.yml --config='redocly.yaml' -t custom.hbs
## Build Meshery GraphQL API documentation
graphql-docs-build:
cd docs; bundle exec rake graphql:compile_docs
## Build Meshery GraphQl API specifications
graphql-build: dep-check
cd server; cd internal/graphql; go run -mod=mod github.com/99designs/gqlgen generate
## testing
test-setup-ui:
cd ui; npm ci; npx playwright install --with-deps; cd ..
test-ui:
cd ui; npm run test:e2e; cd ..
#-----------------------------------------------------------------------------
# Dependencies
#-----------------------------------------------------------------------------
.PHONY: dep-check
#.SILENT: dep-check
INSTALLED_GO_VERSION=$(shell go version)
dep-check:
ifeq (,$(findstring $(GOVERSION), $(INSTALLED_GO_VERSION)))
# Only send a warning.
@echo "Dependency missing: go$(GOVERSION). Ensure 'go$(GOVERSION).x' is installed and available in your 'PATH'"
@echo "GOVERSION: " $(GOVERSION)
@echo "INSTALLED_GO_VERSION: " $(INSTALLED_GO_VERSION)
# Force error and stop.
# $(error Found $(INSTALLED_GO_VERSION). \
# Required golang version is: 'go$(GOVERSION).x'. \
# Ensure go '$(GOVERSION).x' is installed and available in your 'PATH'.)
endif