This repository has been archived by the owner on Mar 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
194 lines (151 loc) · 5.46 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
# 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 = git.openstack.org
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)
PKG := $(shell awk '/^package: / { print $$2 }' glide.yaml)
DEST := $(GOPATH)/src/$(GIT_HOST)/openstack/$(BASE_DIR)
DEST := $(GOPATH)/src/$(PKG)
SOURCES := $(shell find $(DEST) -name '*.go')
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)
REGISTRY ?= dims
# CTI targets
depend: work
ifeq ($(wildcard $(DEST)/vendor/.*),)
cd $(DEST) && glide install --strip-vendor
endif
depend-update: work
cd $(DEST) && glide update
build: openstack-cloud-controller-manager cinder-provisioner cinder-flex-volume-driver cinder-csi-plugin k8s-keystone-auth
openstack-cloud-controller-manager: depend $(SOURCES)
cd $(DEST) && CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags "-X 'main.version=${VERSION}'" \
-o openstack-cloud-controller-manager \
cmd/openstack-cloud-controller-manager/main.go
cinder-provisioner: depend $(SOURCES)
cd $(DEST) && CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags "-X 'main.version=${VERSION}'" \
-o cinder-provisioner \
cmd/cinder-provisioner/main.go
cinder-csi-plugin: depend $(SOURCES)
cd $(DEST) && CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags "-X 'main.version=${VERSION}'" \
-o cinder-csi-plugin \
cmd/cinder-csi-plugin/main.go
cinder-flex-volume-driver: depend $(SOURCES)
cd $(DEST) && CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags "-X 'main.version=${VERSION}'" \
-o cinder-flex-volume-driver \
cmd/cinder-flex-volume-driver/main.go
k8s-keystone-auth: depend $(SOURCES)
cd $(DEST) && CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags "-X 'main.version=${VERSION}'" \
-o k8s-keystone-auth \
cmd/k8s-keystone-auth/main.go
test: unit functional
unit: depend
cd $(DEST) && go test -tags=unit $(shell glide novendor) $(TESTARGS)
functional:
@echo "$@ not yet implemented"
fmt: work
cd $(DEST) && go fmt ./...
vet: work
cd $(DEST) && go vet ./...
cover: depend
cd $(DEST) && go test -tags=unit $(shell glide novendor) -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
work: $(GOPATH) $(DEST)
$(GOPATH):
mkdir -p $(GOPATH)
$(DEST): $(GOPATH)
mkdir -p $(shell dirname $(DEST))
ln -s $(PWD) $(DEST)
.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 .bindep openstack-cloud-controller-manager cinder-flex-volume-driver cinder-provisioner cinder-csi-plugin k8s-keystone-auth
realclean: clean
rm -rf vendor
if [ "$(GOPATH)" = "$(GOPATH_DEFAULT)" ]; then \
rm -rf $(GOPATH); \
fi
shell: work
cd $(DEST) && $(SHELL) -i
images: image-controller-manager image-flex-volume-driver image-provisioner image-csi-plugin image-k8s-keystone-auth
image-controller-manager: depend 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: depend 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: depend 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: depend 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: depend 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
version:
@echo ${VERSION}
.PHONY: bindep build clean cover depend docs fmt functional lint realclean \
relnotes test translation version