argo-cd

Форк
0
/
Makefile 
653 строки · 22.7 Кб
1
PACKAGE=github.com/argoproj/argo-cd/v2/common
2
CURRENT_DIR=$(shell pwd)
3
DIST_DIR=${CURRENT_DIR}/dist
4
CLI_NAME=argocd
5
BIN_NAME=argocd
6

7
GEN_RESOURCES_CLI_NAME=argocd-resources-gen
8

9
HOST_OS:=$(shell go env GOOS)
10
HOST_ARCH:=$(shell go env GOARCH)
11

12
TARGET_ARCH?=linux/amd64
13

14
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
15
BUILD_DATE:=$(if $(BUILD_DATE),$(BUILD_DATE),$(shell date -u +'%Y-%m-%dT%H:%M:%SZ'))
16
GIT_COMMIT:=$(if $(GIT_COMMIT),$(GIT_COMMIT),$(shell git rev-parse HEAD))
17
GIT_TAG:=$(if $(GIT_TAG),$(GIT_TAG),$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi))
18
GIT_TREE_STATE:=$(if $(GIT_TREE_STATE),$(GIT_TREE_STATE),$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi))
19
VOLUME_MOUNT=$(shell if test "$(go env GOOS)" = "darwin"; then echo ":delegated"; elif test selinuxenabled; then echo ":delegated"; else echo ""; fi)
20
KUBECTL_VERSION=$(shell go list -m k8s.io/client-go | head -n 1 | rev | cut -d' ' -f1 | rev)
21

22
GOPATH?=$(shell if test -x `which go`; then go env GOPATH; else echo "$(HOME)/go"; fi)
23
GOCACHE?=$(HOME)/.cache/go-build
24

25
DOCKER_SRCDIR?=$(GOPATH)/src
26
DOCKER_WORKDIR?=/go/src/github.com/argoproj/argo-cd
27

28
ARGOCD_PROCFILE?=Procfile
29

30
# Strict mode has been disabled in latest versions of mkdocs-material.
31
# Thus pointing to the older image of mkdocs-material matching the version used by argo-cd.
32
MKDOCS_DOCKER_IMAGE?=squidfunk/mkdocs-material:4.1.1
33
MKDOCS_RUN_ARGS?=
34

35
# Configuration for building argocd-test-tools image
36
TEST_TOOLS_NAMESPACE?=
37
TEST_TOOLS_IMAGE=argocd-test-tools
38
TEST_TOOLS_TAG?=latest
39
ifdef TEST_TOOLS_NAMESPACE
40
TEST_TOOLS_PREFIX=${TEST_TOOLS_NAMESPACE}/
41
endif
42

43
# You can change the ports where ArgoCD components will be listening on by
44
# setting the appropriate environment variables before running make.
45
ARGOCD_E2E_APISERVER_PORT?=8080
46
ARGOCD_E2E_REPOSERVER_PORT?=8081
47
ARGOCD_E2E_REDIS_PORT?=6379
48
ARGOCD_E2E_DEX_PORT?=5556
49
ARGOCD_E2E_YARN_HOST?=localhost
50
ARGOCD_E2E_DISABLE_AUTH?=
51

52
ARGOCD_E2E_TEST_TIMEOUT?=90m
53

54
ARGOCD_IN_CI?=false
55
ARGOCD_TEST_E2E?=true
56
ARGOCD_BIN_MODE?=true
57

58
ARGOCD_LINT_GOGC?=20
59

60
# Depending on where we are (legacy or non-legacy pwd), we need to use
61
# different Docker volume mounts for our source tree
62
LEGACY_PATH=$(GOPATH)/src/github.com/argoproj/argo-cd
63
ifeq ("$(PWD)","$(LEGACY_PATH)")
64
DOCKER_SRC_MOUNT="$(DOCKER_SRCDIR):/go/src$(VOLUME_MOUNT)"
65
else
66
DOCKER_SRC_MOUNT="$(PWD):/go/src/github.com/argoproj/argo-cd$(VOLUME_MOUNT)"
67
endif
68

69
# User and group IDs to map to the test container
70
CONTAINER_UID=$(shell id -u)
71
CONTAINER_GID=$(shell id -g)
72

73
# Set SUDO to sudo to run privileged commands with sudo
74
SUDO?=
75

76
# Runs any command in the argocd-test-utils container in server mode
77
# Server mode container will start with uid 0 and drop privileges during runtime
78
define run-in-test-server
79
	$(SUDO) docker run --rm -it \
80
		--name argocd-test-server \
81
		-u $(CONTAINER_UID):$(CONTAINER_GID) \
82
		-e USER_ID=$(CONTAINER_UID) \
83
		-e HOME=/home/user \
84
		-e GOPATH=/go \
85
		-e GOCACHE=/tmp/go-build-cache \
86
		-e ARGOCD_IN_CI=$(ARGOCD_IN_CI) \
87
		-e ARGOCD_E2E_TEST=$(ARGOCD_E2E_TEST) \
88
		-e ARGOCD_E2E_YARN_HOST=$(ARGOCD_E2E_YARN_HOST) \
89
		-e ARGOCD_E2E_DISABLE_AUTH=$(ARGOCD_E2E_DISABLE_AUTH) \
90
		-e ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} \
91
		-e ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} \
92
		-e ARGOCD_GPG_DATA_PATH=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} \
93
		-e ARGOCD_APPLICATION_NAMESPACES \
94
		-e GITHUB_TOKEN \
95
		-v ${DOCKER_SRC_MOUNT} \
96
		-v ${GOPATH}/pkg/mod:/go/pkg/mod${VOLUME_MOUNT} \
97
		-v ${GOCACHE}:/tmp/go-build-cache${VOLUME_MOUNT} \
98
		-v ${HOME}/.kube:/home/user/.kube${VOLUME_MOUNT} \
99
		-v /tmp:/tmp${VOLUME_MOUNT} \
100
		-w ${DOCKER_WORKDIR} \
101
		-p ${ARGOCD_E2E_APISERVER_PORT}:8080 \
102
		-p 4000:4000 \
103
		-p 5000:5000 \
104
		$(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE):$(TEST_TOOLS_TAG) \
105
		bash -c "$(1)"
106
endef
107

108
# Runs any command in the argocd-test-utils container in client mode
109
define run-in-test-client
110
	$(SUDO) docker run --rm -it \
111
	  --name argocd-test-client \
112
		-u $(CONTAINER_UID):$(CONTAINER_GID) \
113
		-e HOME=/home/user \
114
		-e GOPATH=/go \
115
		-e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) \
116
		-e GITHUB_TOKEN \
117
		-e GOCACHE=/tmp/go-build-cache \
118
		-e ARGOCD_LINT_GOGC=$(ARGOCD_LINT_GOGC) \
119
		-v ${DOCKER_SRC_MOUNT} \
120
		-v ${GOPATH}/pkg/mod:/go/pkg/mod${VOLUME_MOUNT} \
121
		-v ${GOCACHE}:/tmp/go-build-cache${VOLUME_MOUNT} \
122
		-v ${HOME}/.kube:/home/user/.kube${VOLUME_MOUNT} \
123
		-v /tmp:/tmp${VOLUME_MOUNT} \
124
		-w ${DOCKER_WORKDIR} \
125
		$(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE):$(TEST_TOOLS_TAG) \
126
		bash -c "$(1)"
127
endef
128

129
#
130
define exec-in-test-server
131
	$(SUDO) docker exec -it -u $(CONTAINER_UID):$(CONTAINER_GID) -e ARGOCD_E2E_RECORD=$(ARGOCD_E2E_RECORD) -e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) argocd-test-server $(1)
132
endef
133

134
PATH:=$(PATH):$(PWD)/hack
135

136
# docker image publishing options
137
DOCKER_PUSH?=false
138
IMAGE_NAMESPACE?=
139
# perform static compilation
140
STATIC_BUILD?=true
141
# build development images
142
DEV_IMAGE?=false
143
ARGOCD_GPG_ENABLED?=true
144
ARGOCD_E2E_APISERVER_PORT?=8080
145

146
override LDFLAGS += \
147
  -X ${PACKAGE}.version=${VERSION} \
148
  -X ${PACKAGE}.buildDate=${BUILD_DATE} \
149
  -X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
150
  -X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}\
151
  -X ${PACKAGE}.kubectlVersion=${KUBECTL_VERSION}\
152
  -X "${PACKAGE}.extraBuildInfo=${EXTRA_BUILD_INFO}"
153

154
ifeq (${STATIC_BUILD}, true)
155
override LDFLAGS += -extldflags "-static"
156
endif
157

158
ifneq (${GIT_TAG},)
159
IMAGE_TAG=${GIT_TAG}
160
LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
161
else
162
IMAGE_TAG?=latest
163
endif
164

165
ifeq (${DOCKER_PUSH},true)
166
ifndef IMAGE_NAMESPACE
167
$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=argoproj))
168
endif
169
endif
170

171
ifdef IMAGE_NAMESPACE
172
IMAGE_PREFIX=${IMAGE_NAMESPACE}/
173
endif
174

175
.PHONY: all
176
all: cli image
177

178
.PHONY: gogen
179
gogen:
180
	export GO111MODULE=off
181
	go generate ./util/argo/...
182

183
.PHONY: protogen
184
protogen: mod-vendor-local protogen-fast
185

186
.PHONY: protogen-fast
187
protogen-fast:
188
	export GO111MODULE=off
189
	./hack/generate-proto.sh
190

191
.PHONY: openapigen
192
openapigen:
193
	export GO111MODULE=off
194
	./hack/update-openapi.sh
195

196
.PHONY: notification-catalog
197
notification-catalog:
198
	go run ./hack/gen-catalog catalog
199

200
.PHONY: notification-docs
201
notification-docs:
202
	go run ./hack/gen-docs
203
	go run ./hack/gen-catalog docs
204

205

206
.PHONY: clientgen
207
clientgen:
208
	export GO111MODULE=off
209
	./hack/update-codegen.sh
210

211
.PHONY: clidocsgen
212
clidocsgen:
213
	go run tools/cmd-docs/main.go
214

215

216
.PHONY: codegen-local
217
codegen-local: mod-vendor-local gogen protogen clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
218
	rm -rf vendor/
219

220
.PHONY: codegen-local-fast
221
codegen-local-fast: gogen protogen-fast clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
222

223
.PHONY: codegen
224
codegen: test-tools-image
225
	$(call run-in-test-client,make codegen-local)
226

227
.PHONY: cli
228
cli: test-tools-image
229
	$(call run-in-test-client, GOOS=${HOST_OS} GOARCH=${HOST_ARCH} make cli-local)
230

231
.PHONY: cli-local
232
cli-local: clean-debug
233
	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${CLI_NAME} ./cmd
234

235
.PHONY: gen-resources-cli-local
236
gen-resources-cli-local: clean-debug
237
	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${GEN_RESOURCES_CLI_NAME} ./hack/gen-resources/cmd
238

239
.PHONY: release-cli
240
release-cli: clean-debug build-ui
241
	make BIN_NAME=argocd-darwin-amd64 GOOS=darwin argocd-all
242
	make BIN_NAME=argocd-darwin-arm64 GOOS=darwin GOARCH=arm64 argocd-all
243
	make BIN_NAME=argocd-linux-amd64 GOOS=linux argocd-all
244
	make BIN_NAME=argocd-linux-arm64 GOOS=linux GOARCH=arm64 argocd-all
245
	make BIN_NAME=argocd-linux-ppc64le GOOS=linux GOARCH=ppc64le argocd-all
246
	make BIN_NAME=argocd-linux-s390x GOOS=linux GOARCH=s390x argocd-all
247
	make BIN_NAME=argocd-windows-amd64.exe GOOS=windows argocd-all
248

249
.PHONY: test-tools-image
250
test-tools-image:
251
ifndef SKIP_TEST_TOOLS_IMAGE
252
	$(SUDO) docker build --build-arg UID=$(CONTAINER_UID) -t $(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE) -f test/container/Dockerfile .
253
	$(SUDO) docker tag $(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE) $(TEST_TOOLS_PREFIX)$(TEST_TOOLS_IMAGE):$(TEST_TOOLS_TAG)
254
endif
255

256
.PHONY: manifests-local
257
manifests-local:
258
	./hack/update-manifests.sh
259

260
.PHONY: manifests
261
manifests: test-tools-image
262
	$(call run-in-test-client,make manifests-local IMAGE_NAMESPACE='${IMAGE_NAMESPACE}' IMAGE_TAG='${IMAGE_TAG}')
263

264
# consolidated binary for cli, util, server, repo-server, controller
265
.PHONY: argocd-all
266
argocd-all: clean-debug
267
	CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${BIN_NAME} ./cmd
268

269
.PHONY: server
270
server: clean-debug
271
	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-server ./cmd
272

273
.PHONY: repo-server
274
repo-server:
275
	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-repo-server ./cmd
276

277
.PHONY: controller
278
controller:
279
	CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd
280

281
.PHONY: build-ui
282
build-ui:
283
	DOCKER_BUILDKIT=1 docker build -t argocd-ui --platform=$(TARGET_ARCH) --target argocd-ui .
284
	find ./ui/dist -type f -not -name gitkeep -delete
285
	docker run -v ${CURRENT_DIR}/ui/dist/app:/tmp/app --rm -t argocd-ui sh -c 'cp -r ./dist/app/* /tmp/app/'
286

287
.PHONY: image
288
ifeq ($(DEV_IMAGE), true)
289
# The "dev" image builds the binaries from the users desktop environment (instead of in Docker)
290
# which speeds up builds. Dockerfile.dev needs to be copied into dist to perform the build, since
291
# the dist directory is under .dockerignore.
292
IMAGE_TAG="dev-$(shell git describe --always --dirty)"
293
image: build-ui
294
	DOCKER_BUILDKIT=1 docker build --platform=$(TARGET_ARCH) -t argocd-base --target argocd-base .
295
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd ./cmd
296
	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-server
297
	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-application-controller
298
	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-repo-server
299
	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-cmp-server
300
	ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-dex
301
	cp Dockerfile.dev dist
302
	DOCKER_BUILDKIT=1 docker build --platform=$(TARGET_ARCH) -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) -f dist/Dockerfile.dev dist
303
else
304
image:
305
	DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) --platform=$(TARGET_ARCH) .
306
endif
307
	@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) ; fi
308

309
.PHONY: armimage
310
armimage:
311
	docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG)-arm .
312

313
.PHONY: builder-image
314
builder-image:
315
	docker build  -t $(IMAGE_PREFIX)argo-cd-ci-builder:$(IMAGE_TAG) --target builder .
316
	@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argo-cd-ci-builder:$(IMAGE_TAG) ; fi
317

318
.PHONY: mod-download
319
mod-download: test-tools-image
320
	$(call run-in-test-client,go mod download)
321

322
.PHONY: mod-download-local
323
mod-download-local:
324
	go mod download && go mod tidy # go mod download changes go.sum https://github.com/golang/go/issues/42970
325

326
.PHONY: mod-vendor
327
mod-vendor: test-tools-image
328
	$(call run-in-test-client,go mod vendor)
329

330
.PHONY: mod-vendor-local
331
mod-vendor-local: mod-download-local
332
	go mod vendor
333

334
# Deprecated - replace by install-tools-local
335
.PHONY: install-lint-tools
336
install-lint-tools:
337
	./hack/install.sh lint-tools
338

339
# Run linter on the code
340
.PHONY: lint
341
lint: test-tools-image
342
	$(call run-in-test-client,make lint-local)
343

344
# Run linter on the code (local version)
345
.PHONY: lint-local
346
lint-local:
347
	golangci-lint --version
348
	# NOTE: If you get a "Killed" OOM message, try reducing the value of GOGC
349
	# See https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
350
	GOGC=$(ARGOCD_LINT_GOGC) GOMAXPROCS=2 golangci-lint run --enable gofmt --fix --verbose --timeout 3000s --max-issues-per-linter 0 --max-same-issues 0
351

352
.PHONY: lint-ui
353
lint-ui: test-tools-image
354
	$(call run-in-test-client,make lint-ui-local)
355

356
.PHONY: lint-ui-local
357
lint-ui-local:
358
	cd ui && yarn lint
359

360
# Build all Go code
361
.PHONY: build
362
build: test-tools-image
363
	mkdir -p $(GOCACHE)
364
	$(call run-in-test-client, make build-local)
365

366
# Build all Go code (local version)
367
.PHONY: build-local
368
build-local:
369
	GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v `go list ./... | grep -v 'resource_customizations\|test/e2e'`
370

371
# Run all unit tests
372
#
373
# If TEST_MODULE is set (to fully qualified module name), only this specific
374
# module will be tested.
375
.PHONY: test
376
test: test-tools-image
377
	mkdir -p $(GOCACHE)
378
	$(call run-in-test-client,make TEST_MODULE=$(TEST_MODULE) test-local)
379

380
# Run all unit tests (local version)
381
.PHONY: test-local
382
test-local:
383
	if test "$(TEST_MODULE)" = ""; then \
384
		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES=`go list ./... | grep -v 'test/e2e'` ./hack/test.sh -coverprofile=coverage.out; \
385
	else \
386
		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES="$(TEST_MODULE)" ./hack/test.sh -coverprofile=coverage.out "$(TEST_MODULE)"; \
387
	fi
388

389
.PHONY: test-race
390
test-race: test-tools-image
391
	mkdir -p $(GOCACHE)
392
	$(call run-in-test-client,make TEST_MODULE=$(TEST_MODULE) test-race-local)
393

394
# Run all unit tests, with data race detection, skipping known failures (local version)
395
.PHONY: test-race-local
396
test-race-local:
397
	if test "$(TEST_MODULE)" = ""; then \
398
		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES=`go list ./... | grep -v 'test/e2e'` ./hack/test.sh -race -coverprofile=coverage.out; \
399
	else \
400
		DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES="$(TEST_MODULE)" ./hack/test.sh -race -coverprofile=coverage.out; \
401
	fi
402

403
# Run the E2E test suite. E2E test servers (see start-e2e target) must be
404
# started before.
405
.PHONY: test-e2e
406
test-e2e:
407
	$(call exec-in-test-server,make test-e2e-local)
408

409
# Run the E2E test suite (local version)
410
.PHONY: test-e2e-local
411
test-e2e-local: cli-local
412
	# NO_PROXY ensures all tests don't go out through a proxy if one is configured on the test system
413
	export GO111MODULE=off
414
	DIST_DIR=${DIST_DIR} RERUN_FAILS=5 PACKAGES="./test/e2e" ARGOCD_E2E_RECORD=${ARGOCD_E2E_RECORD} ARGOCD_GPG_ENABLED=true NO_PROXY=* ./hack/test.sh -timeout $(ARGOCD_E2E_TEST_TIMEOUT) -v
415

416
# Spawns a shell in the test server container for debugging purposes
417
debug-test-server: test-tools-image
418
	$(call run-in-test-server,/bin/bash)
419

420
# Spawns a shell in the test client container for debugging purposes
421
debug-test-client: test-tools-image
422
	$(call run-in-test-client,/bin/bash)
423

424
# Starts e2e server in a container
425
.PHONY: start-e2e
426
start-e2e: test-tools-image
427
	docker version
428
	mkdir -p ${GOCACHE}
429
	$(call run-in-test-server,make ARGOCD_PROCFILE=test/container/Procfile start-e2e-local)
430

431
# Starts e2e server locally (or within a container)
432
.PHONY: start-e2e-local
433
start-e2e-local: mod-vendor-local dep-ui-local cli-local
434
	kubectl create ns argocd-e2e || true
435
	kubectl create ns argocd-e2e-external || true
436
	kubectl create ns argocd-e2e-external-2 || true
437
	kubectl config set-context --current --namespace=argocd-e2e
438
	kustomize build test/manifests/base | kubectl apply -f -
439
	kubectl apply -f https://raw.githubusercontent.com/open-cluster-management/api/a6845f2ebcb186ec26b832f60c988537a58f3859/cluster/v1alpha1/0000_04_clusters.open-cluster-management.io_placementdecisions.crd.yaml
440
	# Create GPG keys and source directories
441
	if test -d /tmp/argo-e2e/app/config/gpg; then rm -rf /tmp/argo-e2e/app/config/gpg/*; fi
442
	mkdir -p /tmp/argo-e2e/app/config/gpg/keys && chmod 0700 /tmp/argo-e2e/app/config/gpg/keys
443
	mkdir -p /tmp/argo-e2e/app/config/gpg/source && chmod 0700 /tmp/argo-e2e/app/config/gpg/source
444
	mkdir -p /tmp/argo-e2e/app/config/plugin && chmod 0700 /tmp/argo-e2e/app/config/plugin
445
	# set paths for locally managed ssh known hosts and tls certs data
446
	ARGOCD_SSH_DATA_PATH=/tmp/argo-e2e/app/config/ssh \
447
	ARGOCD_TLS_DATA_PATH=/tmp/argo-e2e/app/config/tls \
448
	ARGOCD_GPG_DATA_PATH=/tmp/argo-e2e/app/config/gpg/source \
449
	ARGOCD_GNUPGHOME=/tmp/argo-e2e/app/config/gpg/keys \
450
	ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \
451
	ARGOCD_PLUGINCONFIGFILEPATH=/tmp/argo-e2e/app/config/plugin \
452
	ARGOCD_PLUGINSOCKFILEPATH=/tmp/argo-e2e/app/config/plugin \
453
	ARGOCD_E2E_DISABLE_AUTH=false \
454
	ARGOCD_ZJWT_FEATURE_FLAG=always \
455
	ARGOCD_IN_CI=$(ARGOCD_IN_CI) \
456
	BIN_MODE=$(ARGOCD_BIN_MODE) \
457
	ARGOCD_APPLICATION_NAMESPACES=argocd-e2e-external,argocd-e2e-external-2 \
458
	ARGOCD_APPLICATIONSET_CONTROLLER_NAMESPACES=argocd-e2e-external,argocd-e2e-external-2 \
459
	ARGOCD_APPLICATIONSET_CONTROLLER_ALLOWED_SCM_PROVIDERS=http://127.0.0.1:8341,http://127.0.0.1:8342,http://127.0.0.1:8343,http://127.0.0.1:8344 \
460
	ARGOCD_E2E_TEST=true \
461
		goreman -f $(ARGOCD_PROCFILE) start ${ARGOCD_START}
462

463
# Cleans VSCode debug.test files from sub-dirs to prevent them from being included in by golang embed
464
.PHONY: clean-debug
465
clean-debug:
466
	-find ${CURRENT_DIR} -name debug.test -exec rm -f {} +
467

468
.PHONY: clean
469
clean: clean-debug
470
	-rm -rf ${CURRENT_DIR}/dist
471

472
.PHONY: start
473
start: test-tools-image
474
	docker version
475
	$(call run-in-test-server,make ARGOCD_PROCFILE=test/container/Procfile start-local ARGOCD_START=${ARGOCD_START})
476

477
# Starts a local instance of ArgoCD
478
.PHONY: start-local
479
start-local: mod-vendor-local dep-ui-local cli-local
480
	# check we can connect to Docker to start Redis
481
	killall goreman || true
482
	kubectl create ns argocd || true
483
	rm -rf /tmp/argocd-local
484
	mkdir -p /tmp/argocd-local
485
	mkdir -p /tmp/argocd-local/gpg/keys && chmod 0700 /tmp/argocd-local/gpg/keys
486
	mkdir -p /tmp/argocd-local/gpg/source
487
	ARGOCD_ZJWT_FEATURE_FLAG=always \
488
	ARGOCD_IN_CI=false \
489
	ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \
490
	BIN_MODE=$(ARGOCD_BIN_MODE) \
491
	ARGOCD_E2E_TEST=false \
492
	ARGOCD_APPLICATION_NAMESPACES=$(ARGOCD_APPLICATION_NAMESPACES) \
493
		goreman -f $(ARGOCD_PROCFILE) start ${ARGOCD_START}
494

495
# Run goreman start with exclude option , provide exclude env variable with list of services
496
.PHONY: run
497
run:
498
	bash ./hack/goreman-start.sh
499

500

501
# Runs pre-commit validation with the virtualized toolchain
502
.PHONY: pre-commit
503
pre-commit: codegen build lint test
504

505
# Runs pre-commit validation with the local toolchain
506
.PHONY: pre-commit-local
507
pre-commit-local: codegen-local build-local lint-local test-local
508

509
.PHONY: release-precheck
510
release-precheck: manifests
511
	@if [ "$(GIT_TREE_STATE)" != "clean" ]; then echo 'git tree state is $(GIT_TREE_STATE)' ; exit 1; fi
512
	@if [ -z "$(GIT_TAG)" ]; then echo 'commit must be tagged to perform release' ; exit 1; fi
513
	@if [ "$(GIT_TAG)" != "v`cat VERSION`" ]; then echo 'VERSION does not match git tag'; exit 1; fi
514

515
.PHONY: release
516
release: pre-commit release-precheck image release-cli
517

518
.PHONY: build-docs-local
519
build-docs-local:
520
	mkdocs build
521

522
.PHONY: build-docs
523
build-docs:
524
	docker run ${MKDOCS_RUN_ARGS} --rm -it -v ${CURRENT_DIR}:/docs --entrypoint "" ${MKDOCS_DOCKER_IMAGE} sh -c 'pip install -r docs/requirements.txt; mkdocs build'
525

526
.PHONY: serve-docs-local
527
serve-docs-local:
528
	mkdocs serve
529

530
.PHONY: serve-docs
531
serve-docs:
532
	docker run ${MKDOCS_RUN_ARGS} --rm -it -p 8000:8000 -v ${CURRENT_DIR}/site:/site -w /site --entrypoint "" ${MKDOCS_DOCKER_IMAGE} python3 -m http.server --bind 0.0.0.0 8000
533

534

535
# Verify that kubectl can connect to your K8s cluster from Docker
536
.PHONY: verify-kube-connect
537
verify-kube-connect: test-tools-image
538
	$(call run-in-test-client,kubectl version)
539

540
# Show the Go version of local and virtualized environments
541
.PHONY: show-go-version
542
show-go-version: test-tools-image
543
	@echo -n "Local Go version: "
544
	@go version
545
	@echo -n "Docker Go version: "
546
	$(call run-in-test-client,go version)
547

548
# Installs all tools required to build and test ArgoCD locally
549
.PHONY: install-tools-local
550
install-tools-local: install-test-tools-local install-codegen-tools-local install-go-tools-local
551

552
# Installs all tools required for running unit & end-to-end tests (Linux packages)
553
.PHONY: install-test-tools-local
554
install-test-tools-local:
555
	./hack/install.sh kustomize
556
	./hack/install.sh helm-linux
557
	./hack/install.sh gotestsum
558

559
# Installs all tools required for running codegen (Linux packages)
560
.PHONY: install-codegen-tools-local
561
install-codegen-tools-local:
562
	./hack/install.sh codegen-tools
563

564
# Installs all tools required for running codegen (Go packages)
565
.PHONY: install-go-tools-local
566
install-go-tools-local:
567
	./hack/install.sh codegen-go-tools
568

569
.PHONY: dep-ui
570
dep-ui: test-tools-image
571
	$(call run-in-test-client,make dep-ui-local)
572

573
dep-ui-local:
574
	cd ui && yarn install
575

576
start-test-k8s:
577
	go run ./hack/k8s
578

579
.PHONY: list
580
list:
581
	@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
582

583
.PHONY: applicationset-controller
584
applicationset-controller:
585
	GODEBUG="tarinsecurepath=0,zipinsecurepath=0" CGO_ENABLED=0 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-applicationset-controller ./cmd
586

587
.PHONY: checksums
588
checksums:
589
	sha256sum ./dist/$(BIN_NAME)-* | awk -F './dist/' '{print $$1 $$2}' > ./dist/$(BIN_NAME)-$(TARGET_VERSION)-checksums.txt
590

591
.PHONY: snyk-container-tests
592
snyk-container-tests:
593
	./hack/snyk-container-tests.sh
594

595
.PHONY: snyk-non-container-tests
596
snyk-non-container-tests:
597
	./hack/snyk-non-container-tests.sh
598

599
.PHONY: snyk-report
600
snyk-report:
601
	./hack/snyk-report.sh $(target_branch)
602

603
.PHONY: help
604
help:
605
	@echo 'Note: Generally an item w/ (-local) will run inside docker unless you use the -local variant'
606
	@echo
607
	@echo 'Common targets'
608
	@echo
609
	@echo 'all -- make cli and image'
610
	@echo
611
	@echo 'components:'
612
	@echo '  applicationset-controller -- applicationset controller'
613
	@echo '  cli(-local)               -- argocd cli program'
614
	@echo '  controller                -- controller (orchestrator)'
615
	@echo '  repo-server               -- repo server (manage repository instances)'
616
	@echo '  server                    -- argocd web application'
617
	@echo
618
	@echo 'build:'
619
	@echo '  image                     -- make image of the following items'
620
	@echo '  build(-local)             -- compile go'
621
	@echo '  build-docs(-local)        -- build docs'
622
	@echo '  build-ui                  -- compile typescript'
623
	@echo
624
	@echo 'run:'
625
	@echo '  run                       -- run the components locally'
626
	@echo '  serve-docs(-local)        -- expose the documents for viewing in a browser'
627
	@echo
628
	@echo 'release:'
629
	@echo '  release-cli'
630
	@echo '  release-precheck'
631
	@echo '  checksums'
632
	@echo
633
	@echo 'docs:'
634
	@echo '  build-docs(-local)'
635
	@echo '  serve-docs(-local)'
636
	@echo '  notification-docs'
637
	@echo '  clidocsgen'
638
	@echo
639
	@echo 'testing:'
640
	@echo '  test(-local)'
641
	@echo '  start-e2e(-local)'
642
	@echo '  test-e2e(-local)'
643
	@echo '  test-race(-local)'
644
	@echo
645
	@echo 'debug:'
646
	@echo '  list -- list all make targets'
647
	@echo '  install-tools-local -- install all the tools below'
648
	@echo '  install-lint-tools(-local)'
649
	@echo
650
	@echo 'codegen:'
651
	@echo '  codegen(-local) -- if using -local, run the following targets first'
652
	@echo '  install-codegen-tools-local -- run this to install the codegen tools'
653
	@echo '  install-go-tools-local -- run this to install go libraries for codegen'
654

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.