argo-cd
/
Makefile
653 строки · 22.7 Кб
1PACKAGE=github.com/argoproj/argo-cd/v2/common
2CURRENT_DIR=$(shell pwd)
3DIST_DIR=${CURRENT_DIR}/dist
4CLI_NAME=argocd
5BIN_NAME=argocd
6
7GEN_RESOURCES_CLI_NAME=argocd-resources-gen
8
9HOST_OS:=$(shell go env GOOS)
10HOST_ARCH:=$(shell go env GOARCH)
11
12TARGET_ARCH?=linux/amd64
13
14VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
15BUILD_DATE:=$(if $(BUILD_DATE),$(BUILD_DATE),$(shell date -u +'%Y-%m-%dT%H:%M:%SZ'))
16GIT_COMMIT:=$(if $(GIT_COMMIT),$(GIT_COMMIT),$(shell git rev-parse HEAD))
17GIT_TAG:=$(if $(GIT_TAG),$(GIT_TAG),$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi))
18GIT_TREE_STATE:=$(if $(GIT_TREE_STATE),$(GIT_TREE_STATE),$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi))
19VOLUME_MOUNT=$(shell if test "$(go env GOOS)" = "darwin"; then echo ":delegated"; elif test selinuxenabled; then echo ":delegated"; else echo ""; fi)
20KUBECTL_VERSION=$(shell go list -m k8s.io/client-go | head -n 1 | rev | cut -d' ' -f1 | rev)
21
22GOPATH?=$(shell if test -x `which go`; then go env GOPATH; else echo "$(HOME)/go"; fi)
23GOCACHE?=$(HOME)/.cache/go-build
24
25DOCKER_SRCDIR?=$(GOPATH)/src
26DOCKER_WORKDIR?=/go/src/github.com/argoproj/argo-cd
27
28ARGOCD_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.
32MKDOCS_DOCKER_IMAGE?=squidfunk/mkdocs-material:4.1.1
33MKDOCS_RUN_ARGS?=
34
35# Configuration for building argocd-test-tools image
36TEST_TOOLS_NAMESPACE?=
37TEST_TOOLS_IMAGE=argocd-test-tools
38TEST_TOOLS_TAG?=latest
39ifdef TEST_TOOLS_NAMESPACE
40TEST_TOOLS_PREFIX=${TEST_TOOLS_NAMESPACE}/
41endif
42
43# You can change the ports where ArgoCD components will be listening on by
44# setting the appropriate environment variables before running make.
45ARGOCD_E2E_APISERVER_PORT?=8080
46ARGOCD_E2E_REPOSERVER_PORT?=8081
47ARGOCD_E2E_REDIS_PORT?=6379
48ARGOCD_E2E_DEX_PORT?=5556
49ARGOCD_E2E_YARN_HOST?=localhost
50ARGOCD_E2E_DISABLE_AUTH?=
51
52ARGOCD_E2E_TEST_TIMEOUT?=90m
53
54ARGOCD_IN_CI?=false
55ARGOCD_TEST_E2E?=true
56ARGOCD_BIN_MODE?=true
57
58ARGOCD_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
62LEGACY_PATH=$(GOPATH)/src/github.com/argoproj/argo-cd
63ifeq ("$(PWD)","$(LEGACY_PATH)")
64DOCKER_SRC_MOUNT="$(DOCKER_SRCDIR):/go/src$(VOLUME_MOUNT)"
65else
66DOCKER_SRC_MOUNT="$(PWD):/go/src/github.com/argoproj/argo-cd$(VOLUME_MOUNT)"
67endif
68
69# User and group IDs to map to the test container
70CONTAINER_UID=$(shell id -u)
71CONTAINER_GID=$(shell id -g)
72
73# Set SUDO to sudo to run privileged commands with sudo
74SUDO?=
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
78define 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) \
105bash -c "$(1)"
106endef
107
108# Runs any command in the argocd-test-utils container in client mode
109define 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) \
126bash -c "$(1)"
127endef
128
129#
130define 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)
132endef
133
134PATH:=$(PATH):$(PWD)/hack
135
136# docker image publishing options
137DOCKER_PUSH?=false
138IMAGE_NAMESPACE?=
139# perform static compilation
140STATIC_BUILD?=true
141# build development images
142DEV_IMAGE?=false
143ARGOCD_GPG_ENABLED?=true
144ARGOCD_E2E_APISERVER_PORT?=8080
145
146override 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
154ifeq (${STATIC_BUILD}, true)
155override LDFLAGS += -extldflags "-static"
156endif
157
158ifneq (${GIT_TAG},)
159IMAGE_TAG=${GIT_TAG}
160LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
161else
162IMAGE_TAG?=latest
163endif
164
165ifeq (${DOCKER_PUSH},true)
166ifndef IMAGE_NAMESPACE
167$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=argoproj))
168endif
169endif
170
171ifdef IMAGE_NAMESPACE
172IMAGE_PREFIX=${IMAGE_NAMESPACE}/
173endif
174
175.PHONY: all
176all: cli image
177
178.PHONY: gogen
179gogen:
180export GO111MODULE=off
181go generate ./util/argo/...
182
183.PHONY: protogen
184protogen: mod-vendor-local protogen-fast
185
186.PHONY: protogen-fast
187protogen-fast:
188export GO111MODULE=off
189./hack/generate-proto.sh
190
191.PHONY: openapigen
192openapigen:
193export GO111MODULE=off
194./hack/update-openapi.sh
195
196.PHONY: notification-catalog
197notification-catalog:
198go run ./hack/gen-catalog catalog
199
200.PHONY: notification-docs
201notification-docs:
202go run ./hack/gen-docs
203go run ./hack/gen-catalog docs
204
205
206.PHONY: clientgen
207clientgen:
208export GO111MODULE=off
209./hack/update-codegen.sh
210
211.PHONY: clidocsgen
212clidocsgen:
213go run tools/cmd-docs/main.go
214
215
216.PHONY: codegen-local
217codegen-local: mod-vendor-local gogen protogen clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
218rm -rf vendor/
219
220.PHONY: codegen-local-fast
221codegen-local-fast: gogen protogen-fast clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
222
223.PHONY: codegen
224codegen: test-tools-image
225$(call run-in-test-client,make codegen-local)
226
227.PHONY: cli
228cli: test-tools-image
229$(call run-in-test-client, GOOS=${HOST_OS} GOARCH=${HOST_ARCH} make cli-local)
230
231.PHONY: cli-local
232cli-local: clean-debug
233CGO_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
236gen-resources-cli-local: clean-debug
237CGO_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
240release-cli: clean-debug build-ui
241make BIN_NAME=argocd-darwin-amd64 GOOS=darwin argocd-all
242make BIN_NAME=argocd-darwin-arm64 GOOS=darwin GOARCH=arm64 argocd-all
243make BIN_NAME=argocd-linux-amd64 GOOS=linux argocd-all
244make BIN_NAME=argocd-linux-arm64 GOOS=linux GOARCH=arm64 argocd-all
245make BIN_NAME=argocd-linux-ppc64le GOOS=linux GOARCH=ppc64le argocd-all
246make BIN_NAME=argocd-linux-s390x GOOS=linux GOARCH=s390x argocd-all
247make BIN_NAME=argocd-windows-amd64.exe GOOS=windows argocd-all
248
249.PHONY: test-tools-image
250test-tools-image:
251ifndef 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)
254endif
255
256.PHONY: manifests-local
257manifests-local:
258./hack/update-manifests.sh
259
260.PHONY: manifests
261manifests: 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
266argocd-all: clean-debug
267CGO_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
270server: clean-debug
271CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-server ./cmd
272
273.PHONY: repo-server
274repo-server:
275CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-repo-server ./cmd
276
277.PHONY: controller
278controller:
279CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd
280
281.PHONY: build-ui
282build-ui:
283DOCKER_BUILDKIT=1 docker build -t argocd-ui --platform=$(TARGET_ARCH) --target argocd-ui .
284find ./ui/dist -type f -not -name gitkeep -delete
285docker 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
288ifeq ($(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.
292IMAGE_TAG="dev-$(shell git describe --always --dirty)"
293image: build-ui
294DOCKER_BUILDKIT=1 docker build --platform=$(TARGET_ARCH) -t argocd-base --target argocd-base .
295CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd ./cmd
296ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-server
297ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-application-controller
298ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-repo-server
299ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-cmp-server
300ln -sfn ${DIST_DIR}/argocd ${DIST_DIR}/argocd-dex
301cp Dockerfile.dev dist
302DOCKER_BUILDKIT=1 docker build --platform=$(TARGET_ARCH) -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) -f dist/Dockerfile.dev dist
303else
304image:
305DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) --platform=$(TARGET_ARCH) .
306endif
307@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) ; fi
308
309.PHONY: armimage
310armimage:
311docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG)-arm .
312
313.PHONY: builder-image
314builder-image:
315docker 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
319mod-download: test-tools-image
320$(call run-in-test-client,go mod download)
321
322.PHONY: mod-download-local
323mod-download-local:
324go mod download && go mod tidy # go mod download changes go.sum https://github.com/golang/go/issues/42970
325
326.PHONY: mod-vendor
327mod-vendor: test-tools-image
328$(call run-in-test-client,go mod vendor)
329
330.PHONY: mod-vendor-local
331mod-vendor-local: mod-download-local
332go mod vendor
333
334# Deprecated - replace by install-tools-local
335.PHONY: install-lint-tools
336install-lint-tools:
337./hack/install.sh lint-tools
338
339# Run linter on the code
340.PHONY: lint
341lint: 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
346lint-local:
347golangci-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
350GOGC=$(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
353lint-ui: test-tools-image
354$(call run-in-test-client,make lint-ui-local)
355
356.PHONY: lint-ui-local
357lint-ui-local:
358cd ui && yarn lint
359
360# Build all Go code
361.PHONY: build
362build: test-tools-image
363mkdir -p $(GOCACHE)
364$(call run-in-test-client, make build-local)
365
366# Build all Go code (local version)
367.PHONY: build-local
368build-local:
369GODEBUG="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
376test: test-tools-image
377mkdir -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
382test-local:
383if test "$(TEST_MODULE)" = ""; then \
384DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES=`go list ./... | grep -v 'test/e2e'` ./hack/test.sh -coverprofile=coverage.out; \
385else \
386DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES="$(TEST_MODULE)" ./hack/test.sh -coverprofile=coverage.out "$(TEST_MODULE)"; \
387fi
388
389.PHONY: test-race
390test-race: test-tools-image
391mkdir -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
396test-race-local:
397if test "$(TEST_MODULE)" = ""; then \
398DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES=`go list ./... | grep -v 'test/e2e'` ./hack/test.sh -race -coverprofile=coverage.out; \
399else \
400DIST_DIR=${DIST_DIR} RERUN_FAILS=0 PACKAGES="$(TEST_MODULE)" ./hack/test.sh -race -coverprofile=coverage.out; \
401fi
402
403# Run the E2E test suite. E2E test servers (see start-e2e target) must be
404# started before.
405.PHONY: test-e2e
406test-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
411test-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
413export GO111MODULE=off
414DIST_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
417debug-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
421debug-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
426start-e2e: test-tools-image
427docker version
428mkdir -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
433start-e2e-local: mod-vendor-local dep-ui-local cli-local
434kubectl create ns argocd-e2e || true
435kubectl create ns argocd-e2e-external || true
436kubectl create ns argocd-e2e-external-2 || true
437kubectl config set-context --current --namespace=argocd-e2e
438kustomize build test/manifests/base | kubectl apply -f -
439kubectl 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
441if test -d /tmp/argo-e2e/app/config/gpg; then rm -rf /tmp/argo-e2e/app/config/gpg/*; fi
442mkdir -p /tmp/argo-e2e/app/config/gpg/keys && chmod 0700 /tmp/argo-e2e/app/config/gpg/keys
443mkdir -p /tmp/argo-e2e/app/config/gpg/source && chmod 0700 /tmp/argo-e2e/app/config/gpg/source
444mkdir -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
446ARGOCD_SSH_DATA_PATH=/tmp/argo-e2e/app/config/ssh \
447ARGOCD_TLS_DATA_PATH=/tmp/argo-e2e/app/config/tls \
448ARGOCD_GPG_DATA_PATH=/tmp/argo-e2e/app/config/gpg/source \
449ARGOCD_GNUPGHOME=/tmp/argo-e2e/app/config/gpg/keys \
450ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \
451ARGOCD_PLUGINCONFIGFILEPATH=/tmp/argo-e2e/app/config/plugin \
452ARGOCD_PLUGINSOCKFILEPATH=/tmp/argo-e2e/app/config/plugin \
453ARGOCD_E2E_DISABLE_AUTH=false \
454ARGOCD_ZJWT_FEATURE_FLAG=always \
455ARGOCD_IN_CI=$(ARGOCD_IN_CI) \
456BIN_MODE=$(ARGOCD_BIN_MODE) \
457ARGOCD_APPLICATION_NAMESPACES=argocd-e2e-external,argocd-e2e-external-2 \
458ARGOCD_APPLICATIONSET_CONTROLLER_NAMESPACES=argocd-e2e-external,argocd-e2e-external-2 \
459ARGOCD_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 \
460ARGOCD_E2E_TEST=true \
461goreman -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
465clean-debug:
466-find ${CURRENT_DIR} -name debug.test -exec rm -f {} +
467
468.PHONY: clean
469clean: clean-debug
470-rm -rf ${CURRENT_DIR}/dist
471
472.PHONY: start
473start: test-tools-image
474docker 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
479start-local: mod-vendor-local dep-ui-local cli-local
480# check we can connect to Docker to start Redis
481killall goreman || true
482kubectl create ns argocd || true
483rm -rf /tmp/argocd-local
484mkdir -p /tmp/argocd-local
485mkdir -p /tmp/argocd-local/gpg/keys && chmod 0700 /tmp/argocd-local/gpg/keys
486mkdir -p /tmp/argocd-local/gpg/source
487ARGOCD_ZJWT_FEATURE_FLAG=always \
488ARGOCD_IN_CI=false \
489ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \
490BIN_MODE=$(ARGOCD_BIN_MODE) \
491ARGOCD_E2E_TEST=false \
492ARGOCD_APPLICATION_NAMESPACES=$(ARGOCD_APPLICATION_NAMESPACES) \
493goreman -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
497run:
498bash ./hack/goreman-start.sh
499
500
501# Runs pre-commit validation with the virtualized toolchain
502.PHONY: pre-commit
503pre-commit: codegen build lint test
504
505# Runs pre-commit validation with the local toolchain
506.PHONY: pre-commit-local
507pre-commit-local: codegen-local build-local lint-local test-local
508
509.PHONY: release-precheck
510release-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
516release: pre-commit release-precheck image release-cli
517
518.PHONY: build-docs-local
519build-docs-local:
520mkdocs build
521
522.PHONY: build-docs
523build-docs:
524docker 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
527serve-docs-local:
528mkdocs serve
529
530.PHONY: serve-docs
531serve-docs:
532docker 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
537verify-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
542show-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
550install-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
554install-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
561install-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
566install-go-tools-local:
567./hack/install.sh codegen-go-tools
568
569.PHONY: dep-ui
570dep-ui: test-tools-image
571$(call run-in-test-client,make dep-ui-local)
572
573dep-ui-local:
574cd ui && yarn install
575
576start-test-k8s:
577go run ./hack/k8s
578
579.PHONY: list
580list:
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
584applicationset-controller:
585GODEBUG="tarinsecurepath=0,zipinsecurepath=0" CGO_ENABLED=0 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-applicationset-controller ./cmd
586
587.PHONY: checksums
588checksums:
589sha256sum ./dist/$(BIN_NAME)-* | awk -F './dist/' '{print $$1 $$2}' > ./dist/$(BIN_NAME)-$(TARGET_VERSION)-checksums.txt
590
591.PHONY: snyk-container-tests
592snyk-container-tests:
593./hack/snyk-container-tests.sh
594
595.PHONY: snyk-non-container-tests
596snyk-non-container-tests:
597./hack/snyk-non-container-tests.sh
598
599.PHONY: snyk-report
600snyk-report:
601./hack/snyk-report.sh $(target_branch)
602
603.PHONY: help
604help:
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