forked from kubernetes/cloud-provider-openstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
340 lines (281 loc) · 12.4 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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# golang-client Makefile
# Follows the interface defined in the Golang CTI proposed
# in https://review.openstack.org/410355
#REPO_VERSION?=$(shell git describe --tags)
GIT_HOST = k8s.io
PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
# Keep an existing GOPATH, make a private one if it is undefined
GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
GOBIN_DEFAULT := $(GOPATH)/bin
export GOBIN ?= $(GOBIN_DEFAULT)
export GO111MODULE := on
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
PKG := $(shell awk '/^module/ { print $$2 }' go.mod)
DEST := $(GOPATH)/src/$(GIT_HOST)/$(BASE_DIR)
SOURCES := $(shell find $(DEST) -name '*.go' 2>/dev/null)
HAS_LINT := $(shell command -v golint;)
HAS_GOX := $(shell command -v gox;)
HAS_IMPORT_BOSS := $(shell command -v import-boss;)
GOX_PARALLEL ?= 3
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le
DIST_DIRS = find * -type d -exec
GOOS ?= $(shell go env GOOS)
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
GOFLAGS :=
TAGS :=
LDFLAGS := "-w -s -X 'k8s.io/cloud-provider-openstack/pkg/version.Version=${VERSION}'"
REGISTRY ?= k8scloudprovider
# CTI targets
$(GOBIN):
echo "create gobin"
mkdir -p $(GOBIN)
work: $(GOBIN)
build: openstack-cloud-controller-manager cinder-provisioner cinder-flex-volume-driver cinder-csi-plugin k8s-keystone-auth client-keystone-auth octavia-ingress-controller manila-provisioner manila-csi-plugin barbican-kms-plugin magnum-auto-healer
openstack-cloud-controller-manager: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o openstack-cloud-controller-manager \
cmd/openstack-cloud-controller-manager/main.go
cinder-provisioner: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o cinder-provisioner \
cmd/cinder-provisioner/main.go
cinder-csi-plugin: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o cinder-csi-plugin \
cmd/cinder-csi-plugin/main.go
cinder-flex-volume-driver: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o cinder-flex-volume-driver \
cmd/cinder-flex-volume-driver/main.go
k8s-keystone-auth: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o k8s-keystone-auth \
cmd/k8s-keystone-auth/main.go
client-keystone-auth: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o client-keystone-auth \
cmd/client-keystone-auth/main.go
octavia-ingress-controller: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o octavia-ingress-controller \
cmd/octavia-ingress-controller/main.go
manila-provisioner: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o manila-provisioner \
cmd/manila-provisioner/main.go
manila-csi-plugin: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o manila-csi-plugin \
cmd/manila-csi-plugin/main.go
barbican-kms-plugin: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o barbican-kms-plugin \
cmd/barbican-kms-plugin/main.go
magnum-auto-healer: work $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o magnum-auto-healer \
cmd/magnum-auto-healer/main.go
test: unit functional
check: work fmt vet lint import-boss
unit: work
go test -tags=unit $(shell go list ./... | sed -e '/sanity/ { N; d; }' | sed -e '/tests/ {N; d;}' | sed -e '/test/ {N; d;}') $(TESTARGS)
functional:
@echo "$@ not yet implemented"
test-cinder-csi-sanity: work
go test $(GIT_HOST)/$(BASE_DIR)/pkg/csi/cinder/sanity/
test-manila-csi-sanity: work
go test $(GIT_HOST)/$(BASE_DIR)/pkg/csi/manila/sanity/
fmt:
hack/verify-gofmt.sh
lint:
ifndef HAS_LINT
echo "installing lint"
GO111MODULE=off go get -u golang.org/x/lint/golint
endif
hack/verify-golint.sh
import-boss:
ifndef HAS_IMPORT_BOSS
echo "installing import-boss"
GO111MODULE=off go get -u k8s.io/code-generator/cmd/import-boss
endif
hack/verify-import-boss.sh
vet:
go vet ./...
cover: work
go test -tags=unit $(shell go list ./...) -cover
docs:
@echo "$@ not yet implemented"
godoc:
@echo "$@ not yet implemented"
releasenotes:
@echo "Reno not yet implemented for this repo"
translation:
@echo "$@ not yet implemented"
# Do the work here
# Set up the development environment
env:
@echo "PWD: $(PWD)"
@echo "BASE_DIR: $(BASE_DIR)"
@echo "GOPATH: $(GOPATH)"
@echo "GOROOT: $(GOROOT)"
@echo "DEST: $(DEST)"
@echo "PKG: $(PKG)"
go version
go env
# Get our dev/test dependencies in place
bootstrap:
tools/test-setup.sh
.bindep:
virtualenv .bindep
.bindep/bin/pip install -i https://pypi.python.org/simple bindep
bindep: .bindep
@.bindep/bin/bindep -b -f bindep.txt || true
install-distro-packages:
tools/install-distro-packages.sh
clean:
rm -rf _dist .bindep openstack-cloud-controller-manager cinder-flex-volume-driver cinder-provisioner cinder-csi-plugin k8s-keystone-auth client-keystone-auth octavia-ingress-controller manila-provisioner manila-csi-plugin magnum-auto-healer
realclean: clean
rm -rf vendor
if [ "$(GOPATH)" = "$(GOPATH_DEFAULT)" ]; then \
rm -rf $(GOPATH); \
fi
shell:
$(SHELL) -i
images: image-controller-manager image-flex-volume-driver image-provisioner image-csi-plugin image-k8s-keystone-auth image-octavia-ingress-controller image-manila-provisioner image-manila-csi-plugin image-kms-plugin image-magnum-auto-healer
image-controller-manager: work openstack-cloud-controller-manager
ifeq ($(GOOS),linux)
cp openstack-cloud-controller-manager cluster/images/controller-manager
docker build -t $(REGISTRY)/openstack-cloud-controller-manager:$(VERSION) cluster/images/controller-manager
rm cluster/images/controller-manager/openstack-cloud-controller-manager
else
$(error Please set GOOS=linux for building the image)
endif
image-flex-volume-driver: work cinder-flex-volume-driver
ifeq ($(GOOS),linux)
cp cinder-flex-volume-driver cluster/images/flex-volume-driver
docker build -t $(REGISTRY)/cinder-flex-volume-driver:$(VERSION) cluster/images/flex-volume-driver
rm cluster/images/flex-volume-driver/cinder-flex-volume-driver
else
$(error Please set GOOS=linux for building the image)
endif
image-provisioner: work cinder-provisioner
ifeq ($(GOOS),linux)
cp cinder-provisioner cluster/images/cinder-provisioner
docker build -t $(REGISTRY)/cinder-provisioner:$(VERSION) cluster/images/cinder-provisioner
rm cluster/images/cinder-provisioner/cinder-provisioner
else
$(error Please set GOOS=linux for building the image)
endif
image-csi-plugin: work cinder-csi-plugin
ifeq ($(GOOS),linux)
cp cinder-csi-plugin cluster/images/cinder-csi-plugin
docker build -t $(REGISTRY)/cinder-csi-plugin:$(VERSION) cluster/images/cinder-csi-plugin
rm cluster/images/cinder-csi-plugin/cinder-csi-plugin
else
$(error Please set GOOS=linux for building the image)
endif
image-k8s-keystone-auth: work k8s-keystone-auth
ifeq ($(GOOS),linux)
cp k8s-keystone-auth cluster/images/webhook
docker build -t $(REGISTRY)/k8s-keystone-auth:$(VERSION) cluster/images/webhook
rm cluster/images/webhook/k8s-keystone-auth
else
$(error Please set GOOS=linux for building the image)
endif
image-octavia-ingress-controller: work octavia-ingress-controller
ifeq ($(GOOS),linux)
cp octavia-ingress-controller cluster/images/octavia-ingress-controller
docker build -t $(REGISTRY)/octavia-ingress-controller:$(VERSION) cluster/images/octavia-ingress-controller
rm cluster/images/octavia-ingress-controller/octavia-ingress-controller
else
$(error Please set GOOS=linux for building the image)
endif
image-manila-provisioner: work manila-provisioner
ifeq ($(GOOS),linux)
cp manila-provisioner cluster/images/manila-provisioner
docker build -t $(REGISTRY)/manila-provisioner:$(VERSION) cluster/images/manila-provisioner
rm cluster/images/manila-provisioner/manila-provisioner
else
$(error Please set GOOS=linux for building the image)
endif
image-manila-csi-plugin: work manila-csi-plugin
ifeq ($(GOOS),linux)
cp manila-csi-plugin cluster/images/manila-csi-plugin
docker build -t $(REGISTRY)/manila-csi-plugin:$(VERSION) cluster/images/manila-csi-plugin
rm cluster/images/manila-csi-plugin/manila-csi-plugin
else
$(error Please set GOOS=linux for building the image)
endif
image-kms-plugin: work barbican-kms-plugin
ifeq ($(GOOS), linux)
cp barbican-kms-plugin cluster/images/barbican-kms-plugin
docker build -t $(REGISTRY)/barbican-kms-plugin:$(VERSION) cluster/images/barbican-kms-plugin
rm cluster/images/barbican-kms-plugin/barbican-kms-plugin
else
$(error Please set GOOS=linux for building the image)
endif
image-magnum-auto-healer: work magnum-auto-healer
ifeq ($(GOOS),linux)
cp magnum-auto-healer cluster/images/magnum-auto-healer
docker build -t $(REGISTRY)/magnum-auto-healer:$(VERSION) cluster/images/magnum-auto-healer
rm cluster/images/magnum-auto-healer/magnum-auto-healer
else
$(error Please set GOOS=linux for building the image)
endif
upload-images: images
@echo "push images to $(REGISTRY)"
docker login -u="$(DOCKER_USERNAME)" -p="$(DOCKER_PASSWORD)";
docker push $(REGISTRY)/openstack-cloud-controller-manager:$(VERSION)
docker push $(REGISTRY)/cinder-flex-volume-driver:$(VERSION)
docker push $(REGISTRY)/cinder-provisioner:$(VERSION)
docker push $(REGISTRY)/cinder-csi-plugin:$(VERSION)
docker push $(REGISTRY)/k8s-keystone-auth:$(VERSION)
docker push $(REGISTRY)/octavia-ingress-controller:$(VERSION)
docker push $(REGISTRY)/manila-provisioner:$(VERSION)
docker push $(REGISTRY)/manila-csi-plugin:$(VERSION)
docker push $(REGISTRY)/magnum-auto-healer:$(VERSION)
version:
@echo ${VERSION}
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross: work
ifndef HAS_GOX
echo "installing gox"
GO111MODULE=off go get -u github.com/mitchellh/gox
endif
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/openstack-cloud-controller-manager/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/cinder-provisioner/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/cinder-csi-plugin/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/cinder-flex-volume-driver/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/k8s-keystone-auth/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/client-keystone-auth/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/octavia-ingress-controller/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/manila-provisioner/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/manila-csi-plugin/
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/magnum-auto-healer/
.PHONY: dist
dist: build-cross
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf cloud-provider-openstack-$(VERSION)-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r cloud-provider-openstack-$(VERSION)-{}.zip {} \; \
)
.PHONY: bindep build clean cover work docs fmt functional lint import-boss realclean \
relnotes test translation version build-cross dist