forked from argoproj-labs/argocd-image-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (119 loc) · 3.61 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
IMAGE_NAMESPACE?=quay.io/argoprojlabs
IMAGE_NAME=argocd-image-updater
IMAGE_TAG?=latest
ifdef IMAGE_NAMESPACE
IMAGE_PREFIX=${IMAGE_NAMESPACE}/
else
IMAGE_PREFIX=
endif
IMAGE_PUSH?=no
OS?=$(shell go env GOOS)
ARCH?=$(shell go env GOARCH)
OUTDIR?=dist
BINNAME?=argocd-image-updater
CURRENT_DIR=$(shell pwd)
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
GIT_COMMIT=$(shell git rev-parse HEAD)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS=
RELEASE_IMAGE_PLATFORMS?=linux/amd64,linux/arm64
VERSION_PACKAGE=github.com/argoproj-labs/argocd-image-updater/pkg/version
ifeq ($(IMAGE_PUSH), yes)
DOCKERX_PUSH=--push
else
DOCKERX_PUSH=
endif
override LDFLAGS += -extldflags "-static"
override LDFLAGS += \
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitCommit=${GIT_COMMIT} \
-X ${VERSION_PACKAGE}.buildDate=${BUILD_DATE}
MKDOCS_DOCKER_IMAGE?=squidfunk/mkdocs-material:4.1.1
MKDOCS_RUN_ARGS?=
.PHONY: all
all: prereq controller
.PHONY: clean
clean: clean-image
rm -rf vendor/
.PHONY: clean-image
clean-image:
rm -rf dist/
rm -f coverage.out
.PHONY: mod-tidy
mod-tidy:
go mod tidy
.PHONY: mod-download
mod-download:
go mod download
.PHONY: mod-vendor
mod-vendor:
go mod vendor
.PHONY: test
test:
go test -coverprofile coverage.out `go list ./... | egrep -v '(test|mocks|ext/)'`
test-race:
go test -race -coverprofile coverage.out `go list ./... | egrep -v '(test|mocks|ext/)'`
.PHONY: prereq
prereq:
mkdir -p dist
.PHONY: controller
controller:
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags '${LDFLAGS}' -o ${OUTDIR}/${BINNAME} cmd/*.go
.PHONY: image
image: clean-image
docker build \
-t ${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG} \
--pull \
.
.PHONY: multiarch-image
multiarch-image:
docker buildx build \
-t ${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG} \
--progress plain \
--pull \
--platform ${RELEASE_IMAGE_PLATFORMS} ${DOCKERX_PUSH} \
.
.PHONY: multiarch-image
multiarch-image-push:
docker buildx build \
-t ${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG} \
--progress plain \
--pull \
--push \
--platform ${RELEASE_IMAGE_PLATFORMS} ${DOCKERX_PUSH} \
.
.PHONY: image-push
image-push: image
docker push ${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG}
.PHONY: release-binaries
release-binaries:
BINNAME=argocd-image-updater-linux_amd64 OUTDIR=dist/release OS=linux ARCH=amd64 make controller
BINNAME=argocd-image-updater-linux_arm64 OUTDIR=dist/release OS=linux ARCH=arm64 make controller
BINNAME=argocd-image-updater-darwin_amd64 OUTDIR=dist/release OS=darwin ARCH=amd64 make controller
BINNAME=argocd-image-updater-darwin_arm64 OUTDIR=dist/release OS=darwin ARCH=arm64 make controller
BINNAME=argocd-image-updater-win64.exe OUTDIR=dist/release OS=windows ARCH=amd64 make controller
.PHONY: extract-binary
extract-binary:
docker rm argocd-image-updater-${IMAGE_TAG} || true
docker create --name argocd-image-updater-${IMAGE_TAG} ${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG}
docker cp argocd-image-updater-${IMAGE_TAG}:/usr/local/bin/argocd-image-updater /tmp/argocd-image-updater_${IMAGE_TAG}_linux-amd64
docker rm argocd-image-updater-${IMAGE_TAG}
.PHONY: lint
lint:
golangci-lint run
.PHONY: manifests
manifests:
IMAGE_NAMESPACE=${IMAGE_NAMESPACE} ./hack/generate-manifests.sh
.PHONY: codegen
codegen: manifests
.PHONY: run-test
run-test:
docker run -v $(HOME)/.kube:/kube --rm -it \
-e ARGOCD_TOKEN \
${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG} \
--kubeconfig /kube/config \
--argocd-server-addr $(ARGOCD_SERVER) \
--grpc-web
.PHONY: serve-docs
serve-docs:
docker run ${MKDOCS_RUN_ARGS} --rm -it -p 8000:8000 -v ${CURRENT_DIR}:/docs ${MKDOCS_DOCKER_IMAGE} serve -a 0.0.0.0:8000