-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
318 lines (283 loc) · 14.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
BASE=github.com/noironetworks/aci-containers
METADATA_SRC=$(wildcard pkg/metadata/*.go)
IPAM_SRC=$(wildcard pkg/ipam/*.go)
INDEX_SRC=$(wildcard pkg/index/*.go)
APICAPI_SRC=$(wildcard pkg/apicapi/*.go)
EPRPCCLIENT_SRC=$(wildcard pkg/eprpcclient/*.go)
HOSTAGENT_SRC=$(wildcard cmd/hostagent/*.go pkg/hostagent/*.go)
AGENTCNI_SRC=$(wildcard cmd/opflexagentcni/*.go)
CONTROLLER_SRC=$(wildcard cmd/controller/*.go pkg/controller/*.go)
GBPSERVER_SRC=$(wildcard cmd/gbpserver/*.go pkg/apiserver/*.go)
ACIKUBECTL_SRC=$(wildcard cmd/acikubectl/*.go cmd/acikubectl/cmd/*.go)
OVSRESYNC_SRC=$(wildcard cmd/ovsresync/*.go)
SIMPLESERVICE_SRC=$(wildcard cmd/simpleservice/*.go)
UTIL_SRC=$(wildcard pkg/util/*.go)
DEBIAN_FILES=$(wildcard debian/*)
GOPKG_FILES=$(wildcard Gopkg.*)
GOBUILD=noirolabs/gobuild1.14
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
DOCKER_EXT = -dev
else
DOCKER_EXT =
endif
HOSTAGENT_DEPS=${METADATA_SRC} ${IPAM_SRC} ${HOSTAGENT_SRC}
AGENTCNI_DEPS=${METADATA_SRC} ${EPRPCCLIENT_SRC} ${AGENTCNI_SRC}
CONTROLLER_DEPS= \
${METADATA_SRC} ${IPAM_SRC} ${INDEX_SRC} \
${APICAPI_SRC} ${CONTROLLER_SRC}
ACIKUBECTL_DEPS=${METADATA_SRC} ${ACIKUBECTL_SRC}
OVSRESYNC_DEPS=${METADATA_SRC} ${OVSRESYNC_SRC}
SIMPLESERVICE_DEPS=${SIMPLESERVICE_SRC}
DIST_FILE=aci-containers.tgz
DOCKER_HUB_ID ?= noiro
DOCKER_TAG ?=
BUILD_CMD ?= go build -v -trimpath
BUILD_CMD_RACE ?= go build -v -trimpath -race
TEST_CMD ?= go test -cover
TEST_ARGS ?=
INSTALL_CMD ?= go install -v
GOFMT_CHK_CMD := gofmt -s -l
GOFMT_FIX_CMD := gofmt -s -w
LINT_CMD := golangci-lint
GIT_COMMIT=$(shell scripts/getGitCommit.sh)
PKG_NAME_CONTROLLER=github.com/noironetworks/aci-containers/pkg/controller
PKG_NAME_GBPSERVER=github.com/noironetworks/aci-containers/pkg/gbpserver
PKG_NAME_HOSTAGENT=github.com/noironetworks/aci-containers/pkg/hostagent
PKG_NAME_ACI_CONTAINERS_OPERATOR=github.com/noironetworks/aci-containers/pkg/acicontainersoperator
STATIC_BUILD_CMD_CGO ?= CGO_ENABLED=1 GOOS=linux ${BUILD_CMD} \
-ldflags="\
-X ${PKG_NAME_CONTROLLER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_CONTROLLER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_GBPSERVER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_GBPSERVER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_HOSTAGENT}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_HOSTAGENT}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_ACI_CONTAINERS_OPERATOR}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_ACI_CONTAINERS_OPERATOR}.gitCommit=${GIT_COMMIT} \
-s -w" -a -installsuffix cgo
STATIC_BUILD_CMD ?= CGO_ENABLED=0 GOOS=linux ${BUILD_CMD} \
-ldflags="\
-X ${PKG_NAME_CONTROLLER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_CONTROLLER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_GBPSERVER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_GBPSERVER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_HOSTAGENT}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_HOSTAGENT}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_ACI_CONTAINERS_OPERATOR}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_ACI_CONTAINERS_OPERATOR}.gitCommit=${GIT_COMMIT} \
-s -w" -a -installsuffix cgo
DOCKER_BUILD_CMD ?= docker build
STATIC_BUILD_RACE_CMD ?= CGO_ENABLED=1 GOOS=linux ${BUILD_CMD_RACE} \
-ldflags="\
-X ${PKG_NAME_CONTROLLER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_CONTROLLER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_GBPSERVER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_GBPSERVER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_HOSTAGENT}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_HOSTAGENT}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_ACI_CONTAINERS_OPERATOR}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_ACI_CONTAINERS_OPERATOR}.gitCommit=${GIT_COMMIT} \
-s -w" -a -installsuffix cgo
.PHONY: clean goinstall check all
all: dist/aci-containers-host-agent dist/opflex-agent-cni \
dist/netop-cni dist/aci-containers-controller dist/acikubectl dist/ovsresync \
dist/gbpserver dist/aci-containers-operator dist/aci-containers-webhook dist/aci-containers-certmanager
all-static: dist-static/aci-containers-host-agent \
dist-static/aci-containers-host-agent-ovscni \
dist-static/opflex-agent-cni dist-static/netop-cni \
dist-static/aci-containers-controller dist-static/ovsresync dist-static/gbpserver \
dist-static/aci-containers-operator dist-static/aci-containers-webhook \
dist-static/aci-containers-certmanager
all-static-race: dist-static-race/aci-containers-host-agent \
dist-static-race/aci-containers-host-agent-ovscni \
dist-static-race/opflex-agent-cni dist-static-race/aci-containers-controller \
dist-static-race/ovsresync dist-static-race/gbpserver \
dist-static-race/aci-containers-operator
go-targets: nodep-opflex-agent-cni nodep-aci-containers-host-agent nodep-aci-containers-controller gbpserver
go-build:
docker run --rm -m 16g -v ${PWD}:/go/src/github.com/noironetworks/aci-containers -w /go/src/github.com/noironetworks/aci-containers --network=host -it ${GOBUILD} make go-targets
go-gbp-build:
docker run --rm -m 16g -v ${PWD}:/go/src/github.com/noironetworks/aci-containers -w /go/src/github.com/noironetworks/aci-containers --network=host -it ${GOBUILD} make go-gbp-target
go-gbp-target: gbpserver
clean-dist-static:
rm -rf dist-static/*
clean-dist-static-race:
rm -rf dist-static-race/*
clean-dist:
rm -rf dist
clean: clean-dist
PACKAGE = aci-containers
VERSION_BASE ?= 1.9.0
VERSION_SUFFIX ?=
VERSION = ${VERSION_BASE}${VERSION_SUFFIX}
BUILD_NUMBER ?= 0
PACKAGE_DIR = ${PACKAGE}-${VERSION}
GOSRC_PATH = ${PACKAGE_DIR}/src/github.com/noironetworks/aci-containers
dist: ${METADATA_SRC} \
${IPAM_SRC} \
${INDEX_SRC} \
${APICAPI_SRC} \
${EPRPCCLIENT_SRC} \
${HOSTAGENT_SRC} \
${AGENTCNI_SRC} \
${CONTROLLER_SRC} \
${ACIKUBECTL_SRC} \
${OVSRESYNC_SRC} \
${SIMPLESERVICE} \
${UTIL_SRC} \
${DEBIAN_FILES} ${GOPKG_FILES} Makefile
- rm -rf ${PACKAGE_DIR}
mkdir -p ${GOSRC_PATH}
cp --parents -r $^ ${GOSRC_PATH}/
mv ${GOSRC_PATH}/debian ${PACKAGE_DIR}/
sed -e "s/@PACKAGE_VERSION@/${VERSION}/" \
-e "s/@BUILD_NUMBER@/${BUILD_NUMBER}/" \
${PACKAGE_DIR}/debian/changelog.in \
> ${PACKAGE_DIR}/debian/changelog
tar cvzf ${DIST_FILE} ${PACKAGE_DIR}
rm -rf ${PACKAGE_DIR}
goinstall:
${INSTALL_CMD} ${BASE}/cmd/opflexagentcni
${INSTALL_CMD} ${BASE}/cmd/controller
${INSTALL_CMD} ${BASE}/cmd/hostagent
${INSTALL_CMD} ${BASE}/cmd/acikubectl
${INSTALL_CMD} ${BASE}/cmd/acicontainersoperator
${INSTALL_CMD} ${BASE}/cmd/webhook
${INSTALL_CMD} ${BASE}/cmd/certmanager
dist/opflex-agent-cni: ${AGENTCNI_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist/netop-cni: ${AGENTCNI_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist-static/opflex-agent-cni: ${AGENTCNI_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist-static/netop-cni: ${AGENTCNI_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist/aci-containers-host-agent: ${HOSTAGENT_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/hostagent
dist-static/aci-containers-host-agent: ${HOSTAGENT_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/hostagent
dist-static/aci-containers-host-agent-ovscni: ${HOSTAGENT_DEPS}
${STATIC_BUILD_CMD_CGO} -tags ovscni -o $@ ${BASE}/cmd/hostagent
dist-static-race/aci-containers-host-agent: ${HOSTAGENT_DEPS}
${STATIC_BUILD_RACE_CMD} -o $@ ${BASE}/cmd/hostagent
dist-static-race/aci-containers-host-agent-ovscni: ${HOSTAGENT_DEPS}
${STATIC_BUILD_RACE_CMD} -tags ovscni -o $@ ${BASE}/cmd/hostagent
dist-static-race/opflex-agent-cni: ${AGENTCNI_DEPS}
${STATIC_BUILD_RACE_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist-static-race/aci-containers-controller: ${CONTROLLER_DEPS}
${STATIC_BUILD_RACE_CMD} -o $@ ${BASE}/cmd/controller
dist-static-race/gbpserver:
${STATIC_BUILD_RACE_CMD} -o $@ ${BASE}/cmd/gbpserver
dist-static-race/aci-containers-operator:
${STATIC_BUILD_RACE_CMD} -o $@ ${BASE}/cmd/acicontainersoperator
dist-static-race/ovsresync:
${STATIC_BUILD_RACE_CMD} -o $@ ${BASE}/cmd/ovsresync
dist/aci-containers-controller: ${CONTROLLER_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/controller
dist-static/aci-containers-controller: ${CONTROLLER_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/controller
dist-static/gbpserver:
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/gbpserver
dist/gbpserver:
${BUILD_CMD} -o $@ ${BASE}/cmd/gbpserver
gbpserver:
${STATIC_BUILD_CMD} -o dist-static/gbpserver ${BASE}/cmd/gbpserver
nodep-aci-containers-controller:
${STATIC_BUILD_CMD} -o dist-static/aci-containers-controller ${BASE}/cmd/controller
nodep-aci-containers-host-agent:
${STATIC_BUILD_CMD} -o dist-static/aci-containers-host-agent ${BASE}/cmd/hostagent
nodep-opflex-agent-cni:
${STATIC_BUILD_CMD} -o dist-static/opflex-agent-cni ${BASE}/cmd/opflexagentcni
dist/acikubectl: ${ACIKUBECTL_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/acikubectl
dist-static/acikubectl: ${ACIKUBECTL_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/acikubectl
dist/aci-containers-operator:
${BUILD_CMD} -o $@ ${BASE}/cmd/acicontainersoperator
dist-static/aci-containers-operator:
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/acicontainersoperator
dist/aci-containers-webhook:
${BUILD_CMD} -o $@ ${BASE}/cmd/webhook
dist-static/aci-containers-webhook:
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/webhook
dist/aci-containers-certmanager:
${BUILD_CMD} -o $@ ${BASE}/cmd/certmanager
dist-static/aci-containers-certmanager:
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/certmanager
dist/ovsresync: ${OVSRESYNC_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/ovsresync
dist-static/ovsresync: ${OVSRESYNC_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/ovsresync
dist/simpleservice: ${SIMPLESERVICE_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/simpleservice
dist-static/simpleservice: ${SIMPLESERVICE_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/simpleservice
container-gbpserver: dist-static/gbpserver
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/gbp-server${DOCKER_TAG} -f ./docker/Dockerfile-gbpserver .
container-host: dist-static/aci-containers-host-agent dist-static/netop-cni dist-static/opflex-agent-cni
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-host${DOCKER_TAG} -f ./docker/Dockerfile-host${DOCKER_EXT} .
container-host-ovscni: dist-static/aci-containers-host-agent-ovscni dist-static/opflex-agent-cni dist-static/netop-cni
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-host-chained${DOCKER_TAG} -f ./docker/Dockerfile-host-chained${DOCKER_EXT} .
container-controller: dist-static/aci-containers-controller
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-controller${DOCKER_TAG} -f ./docker/Dockerfile-controller${DOCKER_EXT} .
container-openvswitch: dist-static/ovsresync
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/openvswitch${DOCKER_TAG} -f ./docker/Dockerfile-openvswitch .
container-cnideploy:
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/cnideploy${DOCKER_TAG} -f ./docker/Dockerfile-cnideploy .
container-simpleservice: dist-static/simpleservice
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/simpleservice${DOCKER_TAG} -f ./docker/Dockerfile-simpleservice .
container-operator: dist-static/aci-containers-operator
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-operator${DOCKER_TAG} -f ./docker/Dockerfile-operator .
container-webhook: dist-static/aci-containers-webhook
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-webhook${DOCKER_TAG} -f ./docker/Dockerfile-webhook .
container-certmanager: dist-static/aci-containers-certmanager
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-certmanager${DOCKER_TAG} -f ./docker/Dockerfile-certmanager .
check-gofmt:
@${GOFMT_CHK_CMD} pkg | grep ".go"; test $$? -ne 0 || exit 1
fix-gofmt:
@${GOFMT_FIX_CMD} pkg
lint:
@${LINT_CMD} run
check: check-gofmt check-ipam check-index check-apicapi check-controller check-hostagent check-gbpserver check-webhook check-certmanager check-acicontainersoperator
check-ipam:
cd pkg/ipam; ${TEST_CMD} -coverprofile=../../covprof-ipam ${TEST_ARGS}
check-index:
${TEST_CMD} -coverprofile=covprof-index ${BASE}/pkg/index ${TEST_ARGS}
check-apicapi:
${TEST_CMD} -coverprofile=covprof-apicapi ${BASE}/pkg/apicapi ${TEST_ARGS} && ./exclude-covprof.sh covprof-apicapi exclude-covprof.conf
check-hostagent: test-tools
KUBEBUILDER_ASSETS=/tmp/kubebuilder/bin ${TEST_CMD} -coverprofile=covprof-hostagent ${BASE}/pkg/hostagent ${TEST_ARGS} && ./exclude-covprof.sh covprof-hostagent exclude-covprof.conf
check-controller:
${TEST_CMD} -coverprofile=covprof-controller ${BASE}/pkg/controller ${TEST_ARGS} && ./exclude-covprof.sh covprof-controller exclude-covprof.conf
check-gbpserver:
${TEST_CMD} -coverprofile=covprof-gbpserver ${BASE}/pkg/gbpserver/... ${TEST_ARGS} && ./exclude-covprof.sh covprof-gbpserver exclude-covprof.conf
check-webhook:
${TEST_CMD} -coverprofile=covprof-webhook ${BASE}/cmd/webhook ${BASE}/pkg/webhook ${TEST_ARGS} && ./exclude-covprof.sh covprof-webhook exclude-covprof.conf
check-certmanager:
${TEST_CMD} -coverprofile=covprof-certmanager ${BASE}/cmd/certmanager ${TEST_ARGS} && ./exclude-covprof.sh covprof-certmanager exclude-covprof.conf
check-acicontainersoperator:
${TEST_CMD} -coverprofile=covprof-acicontainersoperator ${BASE}/cmd/acicontainersoperator ${TEST_ARGS} && ./exclude-covprof.sh covprof-acicontainersoperator exclude-covprof.conf
.PHONY: test-tools
test-tools:
. ./tools/setup-envtest.bash ; setup_envs
echo ${TEST_ASSET_KUBECTL}
DEB_PKG_DIR=build-deb-pkg
dsc: dist
- rm -rf ${DEB_PKG_DIR}
mkdir -p ${DEB_PKG_DIR}
cp ${DIST_FILE} ${DEB_PKG_DIR}/
tar -C $(DEB_PKG_DIR)/ -xf $(DEB_PKG_DIR)/$(DIST_FILE)
mv $(DEB_PKG_DIR)/$(DIST_FILE) $(DEB_PKG_DIR)/$(PACKAGE)_$(VERSION).orig.tar.gz
cd $(DEB_PKG_DIR)/$(PACKAGE)-$(VERSION)/; \
dpkg-buildpackage -d -us -uc -rfakeroot -S
deb: dist
- rm -rf ${DEB_PKG_DIR}
mkdir -p ${DEB_PKG_DIR}
cp ${DIST_FILE} ${DEB_PKG_DIR}/
tar -C $(DEB_PKG_DIR)/ -xf $(DEB_PKG_DIR)/$(DIST_FILE)
mv $(DEB_PKG_DIR)/$(DIST_FILE) $(DEB_PKG_DIR)/$(PACKAGE)_$(VERSION).orig.tar.gz
cd $(DEB_PKG_DIR)/$(PACKAGE)-$(VERSION)/; \
dpkg-buildpackage -us -uc -rfakeroot -b
cp $(DEB_PKG_DIR)/*.deb .
rm -rf $(DEB_PKG_DIR)