2019-06-05 19:58:11 +00:00
|
|
|
PACKAGE=github.com/argoproj/argo-cd/common
|
2018-02-15 00:53:07 +00:00
|
|
|
CURRENT_DIR=$(shell pwd)
|
|
|
|
|
DIST_DIR=${CURRENT_DIR}/dist
|
2018-04-23 07:18:59 +00:00
|
|
|
CLI_NAME=argocd
|
2018-02-15 00:53:07 +00:00
|
|
|
|
|
|
|
|
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
|
|
|
|
|
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
|
GIT_COMMIT=$(shell git rev-parse HEAD)
|
|
|
|
|
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
|
|
|
|
|
GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
|
2018-03-08 11:10:11 +00:00
|
|
|
PACKR_CMD=$(shell if [ "`which packr`" ]; then echo "packr"; else echo "go run vendor/github.com/gobuffalo/packr/packr/main.go"; fi)
|
2018-02-15 00:53:07 +00:00
|
|
|
|
2019-08-06 07:24:03 +00:00
|
|
|
define run-in-dev-tool
|
|
|
|
|
docker run --rm -it -u $(shell id -u) -e HOME=/home/user -v ${CURRENT_DIR}:/go/src/github.com/argoproj/argo-cd -w /go/src/github.com/argoproj/argo-cd argocd-dev-tools bash -c "GOPATH=/go $(1)"
|
|
|
|
|
endef
|
|
|
|
|
|
2019-05-23 00:21:56 +00:00
|
|
|
PATH:=$(PATH):$(PWD)/hack
|
|
|
|
|
|
2019-02-01 21:12:52 +00:00
|
|
|
# docker image publishing options
|
2019-05-22 22:59:30 +00:00
|
|
|
DOCKER_PUSH?=false
|
|
|
|
|
IMAGE_TAG?=latest
|
2019-02-01 21:12:52 +00:00
|
|
|
# perform static compilation
|
2019-05-22 22:59:30 +00:00
|
|
|
STATIC_BUILD?=true
|
2019-02-01 21:12:52 +00:00
|
|
|
# build development images
|
2019-05-22 22:59:30 +00:00
|
|
|
DEV_IMAGE?=false
|
2019-06-14 16:34:27 +00:00
|
|
|
# lint is memory and CPU intensive, so we can limit on CI to mitigate OOM
|
|
|
|
|
LINT_GOGC?=off
|
|
|
|
|
LINT_CONCURRENCY?=8
|
2019-06-17 16:39:58 +00:00
|
|
|
# Set timeout for linter
|
|
|
|
|
LINT_DEADLINE?=1m0s
|
2019-02-01 21:12:52 +00:00
|
|
|
|
2018-02-15 00:53:07 +00:00
|
|
|
override LDFLAGS += \
|
|
|
|
|
-X ${PACKAGE}.version=${VERSION} \
|
|
|
|
|
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
|
|
|
|
|
-X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
|
|
|
|
|
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}
|
|
|
|
|
|
2019-02-01 21:12:52 +00:00
|
|
|
ifeq (${STATIC_BUILD}, true)
|
|
|
|
|
override LDFLAGS += -extldflags "-static"
|
|
|
|
|
endif
|
|
|
|
|
|
2018-02-15 00:53:07 +00:00
|
|
|
ifneq (${GIT_TAG},)
|
|
|
|
|
IMAGE_TAG=${GIT_TAG}
|
|
|
|
|
LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq (${DOCKER_PUSH},true)
|
|
|
|
|
ifndef IMAGE_NAMESPACE
|
|
|
|
|
$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=argoproj))
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifdef IMAGE_NAMESPACE
|
|
|
|
|
IMAGE_PREFIX=${IMAGE_NAMESPACE}/
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
.PHONY: all
|
2018-11-17 02:14:52 +00:00
|
|
|
all: cli image argocd-util
|
2018-02-15 00:53:07 +00:00
|
|
|
|
|
|
|
|
.PHONY: protogen
|
|
|
|
|
protogen:
|
|
|
|
|
./hack/generate-proto.sh
|
|
|
|
|
|
2019-04-07 00:18:00 +00:00
|
|
|
.PHONY: openapigen
|
|
|
|
|
openapigen:
|
|
|
|
|
./hack/update-openapi.sh
|
|
|
|
|
|
2018-02-17 01:34:13 +00:00
|
|
|
.PHONY: clientgen
|
|
|
|
|
clientgen:
|
2018-02-16 23:18:37 +00:00
|
|
|
./hack/update-codegen.sh
|
|
|
|
|
|
2019-07-23 18:24:59 +00:00
|
|
|
.PHONY: codegen-local
|
2019-08-06 07:24:03 +00:00
|
|
|
codegen-local: protogen clientgen openapigen manifests-local
|
2019-07-23 18:24:59 +00:00
|
|
|
|
2018-02-17 01:34:13 +00:00
|
|
|
.PHONY: codegen
|
2019-07-23 18:24:59 +00:00
|
|
|
codegen: dev-tools-image
|
2019-08-06 07:24:03 +00:00
|
|
|
$(call run-in-dev-tool,make codegen-local)
|
2019-06-27 21:44:49 +00:00
|
|
|
|
2018-02-18 21:16:24 +00:00
|
|
|
.PHONY: cli
|
2018-06-15 21:29:20 +00:00
|
|
|
cli: clean-debug
|
2019-02-01 21:12:52 +00:00
|
|
|
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${CLI_NAME} ./cmd/argocd
|
2018-04-23 07:18:59 +00:00
|
|
|
|
2018-11-27 21:39:06 +00:00
|
|
|
.PHONY: release-cli
|
|
|
|
|
release-cli: clean-debug image
|
|
|
|
|
docker create --name tmp-argocd-linux $(IMAGE_PREFIX)argocd:$(IMAGE_TAG)
|
|
|
|
|
docker cp tmp-argocd-linux:/usr/local/bin/argocd ${DIST_DIR}/argocd-linux-amd64
|
|
|
|
|
docker cp tmp-argocd-linux:/usr/local/bin/argocd-darwin-amd64 ${DIST_DIR}/argocd-darwin-amd64
|
2018-04-23 07:18:59 +00:00
|
|
|
docker rm tmp-argocd-linux
|
|
|
|
|
|
SSO Support (#152)
This change implements SSO support.
dex is run as a sidecar to the ArgoCD API server, which fronts dex using a reverse proxy. The end result is that the ArgoCD acts as an OIDC provider serving under /api/dex. The login flow begins at /auth/login, which redirects to the Dex's OAuth2 consent page and ultimately directed to the IdP provider's login page, where they enter their credentials. After logging in, the OAuth2 redirect flows back to the client app, ultimately reaching /auth/callback, where the OIDC token claims are signed, and persisted in the users's cookie.
The dex configuration YAML is formulated during startup (through the argocd-util utility), with the configuration values taken from the argocd-cm configmap and the argocd-secret.
The build process was refactored to build argocd-util statically, so that it could be run inside off-the-shelf dex, which is built from alpine. Also, build speed was improved by expanding the default make targets in the Dockerfile, to avoid rebuilding each binary from scratch
Session management was refactored to use more bare-bones jwt library constructs, so we could reuse code from the user/password flow vs. OAuth2 flow.
* Initial SSO support. Run dex as sidecar. Generate dex config from ArgoCD cm and secret
* Sign and write SSO claims to JWT cookie during SSO login. Refactor session manager
* Build argo-util statically so it can run in dex sidecar. Redirect after SSO login
* Simplify app creation process to not require communication to dex gRPC server
2018-05-03 05:02:26 +00:00
|
|
|
.PHONY: argocd-util
|
2018-06-15 21:29:20 +00:00
|
|
|
argocd-util: clean-debug
|
2018-11-29 20:57:31 +00:00
|
|
|
# Build argocd-util as a statically linked binary, so it could run within the alpine-based dex container (argoproj/argo-cd#844)
|
2019-07-29 17:21:19 +00:00
|
|
|
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-util ./cmd/argocd-util
|
SSO Support (#152)
This change implements SSO support.
dex is run as a sidecar to the ArgoCD API server, which fronts dex using a reverse proxy. The end result is that the ArgoCD acts as an OIDC provider serving under /api/dex. The login flow begins at /auth/login, which redirects to the Dex's OAuth2 consent page and ultimately directed to the IdP provider's login page, where they enter their credentials. After logging in, the OAuth2 redirect flows back to the client app, ultimately reaching /auth/callback, where the OIDC token claims are signed, and persisted in the users's cookie.
The dex configuration YAML is formulated during startup (through the argocd-util utility), with the configuration values taken from the argocd-cm configmap and the argocd-secret.
The build process was refactored to build argocd-util statically, so that it could be run inside off-the-shelf dex, which is built from alpine. Also, build speed was improved by expanding the default make targets in the Dockerfile, to avoid rebuilding each binary from scratch
Session management was refactored to use more bare-bones jwt library constructs, so we could reuse code from the user/password flow vs. OAuth2 flow.
* Initial SSO support. Run dex as sidecar. Generate dex config from ArgoCD cm and secret
* Sign and write SSO claims to JWT cookie during SSO login. Refactor session manager
* Build argo-util statically so it can run in dex sidecar. Redirect after SSO login
* Simplify app creation process to not require communication to dex gRPC server
2018-05-03 05:02:26 +00:00
|
|
|
|
2019-07-23 18:24:59 +00:00
|
|
|
.PHONY: dev-tools-image
|
|
|
|
|
dev-tools-image:
|
|
|
|
|
docker build -t argocd-dev-tools ./hack -f ./hack/Dockerfile.dev-tools
|
|
|
|
|
|
2019-08-06 07:24:03 +00:00
|
|
|
.PHONY: manifests-local
|
|
|
|
|
manifests-local:
|
2018-07-30 23:13:54 +00:00
|
|
|
./hack/update-manifests.sh
|
2018-07-17 01:37:41 +00:00
|
|
|
|
2019-08-06 07:24:03 +00:00
|
|
|
.PHONY: manifests
|
|
|
|
|
manifests: dev-tools-image
|
|
|
|
|
$(call run-in-dev-tool,make manifests-local IMAGE_TAG='${IMAGE_TAG}')
|
|
|
|
|
|
|
|
|
|
|
2018-11-27 21:39:06 +00:00
|
|
|
# NOTE: we use packr to do the build instead of go, since we embed swagger files and policy.csv
|
|
|
|
|
# files into the go binary
|
2018-02-16 01:13:47 +00:00
|
|
|
.PHONY: server
|
2018-06-15 21:29:20 +00:00
|
|
|
server: clean-debug
|
2019-03-19 21:25:19 +00:00
|
|
|
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-server ./cmd/argocd-server
|
2019-05-16 18:05:35 +00:00
|
|
|
|
2018-03-07 06:05:07 +00:00
|
|
|
.PHONY: repo-server
|
|
|
|
|
repo-server:
|
2019-07-29 17:21:19 +00:00
|
|
|
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-repo-server ./cmd/argocd-repo-server
|
2018-03-07 06:05:07 +00:00
|
|
|
|
2018-02-22 18:56:14 +00:00
|
|
|
.PHONY: controller
|
|
|
|
|
controller:
|
2019-03-19 21:25:19 +00:00
|
|
|
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd/argocd-application-controller
|
2018-02-23 23:12:11 +00:00
|
|
|
|
2019-02-01 21:12:52 +00:00
|
|
|
.PHONY: packr
|
|
|
|
|
packr:
|
|
|
|
|
go build -o ${DIST_DIR}/packr ./vendor/github.com/gobuffalo/packr/packr/
|
|
|
|
|
|
2018-11-15 11:46:10 +00:00
|
|
|
.PHONY: image
|
2019-02-01 21:12:52 +00:00
|
|
|
ifeq ($(DEV_IMAGE), true)
|
|
|
|
|
# The "dev" image builds the binaries from the users desktop environment (instead of in Docker)
|
|
|
|
|
# which speeds up builds. Dockerfile.dev needs to be copied into dist to perform the build, since
|
|
|
|
|
# the dist directory is under .dockerignore.
|
|
|
|
|
image: packr
|
|
|
|
|
docker build -t argocd-base --target argocd-base .
|
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 dist/packr build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-server ./cmd/argocd-server
|
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 dist/packr build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd/argocd-application-controller
|
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 dist/packr build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-repo-server ./cmd/argocd-repo-server
|
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 dist/packr build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-util ./cmd/argocd-util
|
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 dist/packr build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd ./cmd/argocd
|
|
|
|
|
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 dist/packr build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-darwin-amd64 ./cmd/argocd
|
|
|
|
|
cp Dockerfile.dev dist
|
|
|
|
|
docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) -f dist/Dockerfile.dev dist
|
|
|
|
|
else
|
2018-11-15 11:46:10 +00:00
|
|
|
image:
|
2018-11-27 21:39:06 +00:00
|
|
|
docker build -t $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) .
|
2019-02-01 21:12:52 +00:00
|
|
|
endif
|
2018-11-15 11:46:10 +00:00
|
|
|
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd:$(IMAGE_TAG) ; fi
|
2018-04-25 21:18:30 +00:00
|
|
|
|
2018-02-26 21:47:42 +00:00
|
|
|
.PHONY: builder-image
|
|
|
|
|
builder-image:
|
2018-08-28 23:00:14 +00:00
|
|
|
docker build -t $(IMAGE_PREFIX)argo-cd-ci-builder:$(IMAGE_TAG) --target builder .
|
2019-07-13 00:17:23 +00:00
|
|
|
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argo-cd-ci-builder:$(IMAGE_TAG) ; fi
|
2018-02-26 21:47:42 +00:00
|
|
|
|
2019-02-21 16:30:13 +00:00
|
|
|
.PHONY: dep-ensure
|
|
|
|
|
dep-ensure:
|
2019-03-09 00:22:04 +00:00
|
|
|
dep ensure -no-vendor
|
2019-02-21 16:30:13 +00:00
|
|
|
|
2018-02-15 00:53:07 +00:00
|
|
|
.PHONY: lint
|
|
|
|
|
lint:
|
2019-06-05 01:17:41 +00:00
|
|
|
# golangci-lint does not do a good job of formatting imports
|
|
|
|
|
goimports -local github.com/argoproj/argo-cd -w `find . ! -path './vendor/*' ! -path './pkg/client/*' -type f -name '*.go'`
|
2019-06-17 16:39:58 +00:00
|
|
|
GOGC=$(LINT_GOGC) golangci-lint run --fix --verbose --concurrency $(LINT_CONCURRENCY) --deadline $(LINT_DEADLINE)
|
2018-02-15 00:53:07 +00:00
|
|
|
|
2019-03-28 18:20:51 +00:00
|
|
|
.PHONY: build
|
2019-03-31 05:14:35 +00:00
|
|
|
build:
|
2019-05-28 18:39:13 +00:00
|
|
|
go build -v `go list ./... | grep -v 'resource_customizations\|test/e2e'`
|
2019-03-28 18:20:51 +00:00
|
|
|
|
2018-02-15 00:53:07 +00:00
|
|
|
.PHONY: test
|
2019-03-31 05:14:35 +00:00
|
|
|
test:
|
2019-05-28 18:39:13 +00:00
|
|
|
go test -v -covermode=count -coverprofile=coverage.out `go list ./... | grep -v "test/e2e"`
|
2018-08-09 22:54:15 +00:00
|
|
|
|
2019-06-05 01:17:41 +00:00
|
|
|
.PHONY: cover
|
|
|
|
|
cover:
|
|
|
|
|
go tool cover -html=coverage.out
|
|
|
|
|
|
2018-04-18 20:53:37 +00:00
|
|
|
.PHONY: test-e2e
|
2019-03-24 14:35:57 +00:00
|
|
|
test-e2e: cli
|
2019-05-28 18:39:13 +00:00
|
|
|
go test -v -timeout 10m ./test/e2e
|
2018-02-15 00:53:07 +00:00
|
|
|
|
2019-04-17 17:53:37 +00:00
|
|
|
.PHONY: start-e2e
|
|
|
|
|
start-e2e: cli
|
2019-04-25 22:22:49 +00:00
|
|
|
killall goreman || true
|
2019-07-24 22:50:31 +00:00
|
|
|
# check we can connect to Docker to start Redis
|
|
|
|
|
docker version
|
2019-04-17 17:53:37 +00:00
|
|
|
kubectl create ns argocd-e2e || true
|
2019-07-13 00:17:23 +00:00
|
|
|
kubectl config set-context --current --namespace=argocd-e2e
|
2019-04-17 17:53:37 +00:00
|
|
|
kustomize build test/manifests/base | kubectl apply -f -
|
2019-07-25 00:25:27 +00:00
|
|
|
# set paths for locally managed ssh known hosts and tls certs data
|
2019-08-04 18:35:00 +00:00
|
|
|
ARGOCD_SSH_DATA_PATH=/tmp/argo-e2e/app/config/ssh \
|
|
|
|
|
ARGOCD_TLS_DATA_PATH=/tmp/argo-e2e/app/config/tls \
|
|
|
|
|
goreman start
|
2019-04-17 17:53:37 +00:00
|
|
|
|
2018-06-15 21:29:20 +00:00
|
|
|
# Cleans VSCode debug.test files from sub-dirs to prevent them from being included in packr boxes
|
|
|
|
|
.PHONY: clean-debug
|
|
|
|
|
clean-debug:
|
|
|
|
|
-find ${CURRENT_DIR} -name debug.test | xargs rm -f
|
|
|
|
|
|
2018-02-15 00:53:07 +00:00
|
|
|
.PHONY: clean
|
2018-06-15 21:29:20 +00:00
|
|
|
clean: clean-debug
|
2018-02-15 00:53:07 +00:00
|
|
|
-rm -rf ${CURRENT_DIR}/dist
|
|
|
|
|
|
2019-04-03 22:11:48 +00:00
|
|
|
.PHONY: start
|
|
|
|
|
start:
|
2019-04-09 22:05:14 +00:00
|
|
|
killall goreman || true
|
2019-07-12 16:30:02 +00:00
|
|
|
# check we can connect to Docker to start Redis
|
|
|
|
|
docker version
|
2019-07-24 22:50:31 +00:00
|
|
|
kubens argocd
|
2019-04-03 22:11:48 +00:00
|
|
|
goreman start
|
|
|
|
|
|
2019-02-21 16:30:13 +00:00
|
|
|
.PHONY: pre-commit
|
2019-03-31 05:14:35 +00:00
|
|
|
pre-commit: dep-ensure codegen build lint test
|
2018-02-15 00:53:07 +00:00
|
|
|
|
2018-04-23 07:18:59 +00:00
|
|
|
.PHONY: release-precheck
|
2018-09-24 19:58:17 +00:00
|
|
|
release-precheck: manifests
|
2018-04-23 07:18:59 +00:00
|
|
|
@if [ "$(GIT_TREE_STATE)" != "clean" ]; then echo 'git tree state is $(GIT_TREE_STATE)' ; exit 1; fi
|
|
|
|
|
@if [ -z "$(GIT_TAG)" ]; then echo 'commit must be tagged to perform release' ; exit 1; fi
|
2018-09-26 14:40:42 +00:00
|
|
|
@if [ "$(GIT_TAG)" != "v`cat VERSION`" ]; then echo 'VERSION does not match git tag'; exit 1; fi
|
2018-04-23 07:18:59 +00:00
|
|
|
|
|
|
|
|
.PHONY: release
|
2019-06-17 17:45:32 +00:00
|
|
|
release: pre-commit release-precheck image release-cli
|