forked from kubev2v/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
324 lines (262 loc) · 11.9 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
GOOS ?= `go env GOOS`
GOPATH ?= `go env GOPATH`
GOBIN ?= $(GOPATH)/bin
GO111MODULE = auto
CONTAINER_CMD ?= $(shell command -v podman)
ifeq ($(CONTAINER_CMD),)
CONTAINER_CMD := $(shell command -v docker)
endif
REGISTRY ?= quay.io
REGISTRY_ACCOUNT ?= kubev2v
REGISTRY_TAG ?= devel
VERSION ?= 2.5.0
NAMESPACE ?= konveyor-forklift
CHANNELS ?= development
DEFAULT_CHANNEL ?= development
# Use OPM_OPTS="--use-http" when using a non HTTPS registry
OPM_OPTS ?=
# By default use the controller gen installed by the
# 'controller-gen' target
DEFAULT_CONTROLLER_GEN = $(GOBIN)/controller-gen
CONTROLLER_GEN ?= $(DEFAULT_CONTROLLER_GEN)
# By default use the kubectl installed by the
# 'kubectl' target
DEFAULT_KUBECTL = $(GOBIN)/kubectl
KUBECTL ?= $(DEFAULT_KUBECTL)
# Image URLs to use all building/pushing image targets
CONTROLLER_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-controller:$(REGISTRY_TAG)
API_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-api:$(REGISTRY_TAG)
VALIDATION_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-validation:$(REGISTRY_TAG)
VIRT_V2V_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-virt-v2v:$(REGISTRY_TAG)
VIRT_V2V_WARM_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-virt-v2v-warm:$(REGISTRY_TAG)
OPERATOR_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-operator:$(REGISTRY_TAG)
OPERATOR_BUNDLE_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-operator-bundle:$(REGISTRY_TAG)
OPERATOR_INDEX_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/forklift-operator-index:$(REGISTRY_TAG)
POPULATOR_CONTROLLER_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/populator-controller:$(REGISTRY_TAG)
OVIRT_POPULATOR_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/ovirt-populator:$(REGISTRY_TAG)
OPENSTACK_POPULATOR_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/openstack-populator:$(REGISTRY_TAG)
OVA_PROVIDER_SERVER_IMAGE ?= $(REGISTRY)/$(REGISTRY_ACCOUNT)/ova-provider-server:$(REGISTRY_TAG)
### External images
MUST_GATHER_IMAGE ?= quay.io/kubev2v/forklift-must-gather:latest
MUST_GATHER_API_IMAGE ?= quay.io/kubev2v/forklift-must-gather-api:latest
UI_IMAGE ?= quay.io/kubev2v/forklift-ui:latest
UI_PLUGIN_IMAGE ?= quay.io/kubev2v/forklift-console-plugin:latest
BAZEL_OPTS ?= --verbose_failures
ifneq (,$(findstring /usr/lib64/ccache,$(PATH)))
CCACHE_DIR ?= $${HOME}/.ccache
BAZEL_OPTS += --sandbox_writable_path=$(CCACHE_DIR)
$(shell [ -d $(CCACHE_DIR) ] || mkdir -p $(CCACHE_DIR))
endif
XDG_RUNTIME_DIR ?=
ifneq (,$(XDG_RUNTIME_DIR))
BAZEL_OPTS += --sandbox_writable_path=$${XDG_RUNTIME_DIR}
$(shell [ -d $(XDG_RUNTIME_DIR) ] || mkdir -p $(XDG_RUNTIME_DIR))
endif
ci: all tidy vendor bazel-generate generate-verify
all: test forklift-controller
# Run tests
test: generate fmt vet manifests
go test ./pkg/... ./cmd/... -coverprofile cover.out
# Experimental e2e target
e2e-sanity: e2e-sanity-ovirt e2e-sanity-vsphere
e2e-sanity-ovirt:
# ovirt suite
KUBEVIRT_CLIENT_GO_SCHEME_REGISTRATION_VERSION=v1 go test ./tests/suit -v -ginkgo.focus ".*oVirt.*|.*Forklift.*"
e2e-sanity-vsphere:
# vsphere suit
go test ./tests/suit -v -ginkgo.focus ".*vSphere.*"
e2e-sanity-openstack:
# openstack suit
go test ./tests/suit -v -ginkgo.focus ".*Migration tests for OpenStack.*"
e2e-sanity-openstack-extended:
# openstack extended suit
sudo bash -c 'echo "127.0.0.1 packstack.konveyor-forklift" >>/etc/hosts'
go test ./tests/suit -v -ginkgo.focus ".*Migration Extended tests for OpenStack.*" -ginkgo.parallel.total 1
# Build forklift-controller binary
forklift-controller: generate fmt vet
go build -o bin/forklift-controller github.com/konveyor/forklift-controller/cmd/forklift-controller
# Build manager binary with compiler optimizations disabled
debug: generate fmt vet
go build -o bin/forklift-controller -gcflags=all="-N -l" github.com/konveyor/forklift-controller/cmd/forklift-controller
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
export METRICS_PORT=8888;\
KUBEVIRT_CLIENT_GO_SCHEME_REGISTRATION_VERSION=v1 go run ./cmd/forklift-controller/main.go
# Install CRDs into a cluster
install: manifests kubectl
$(KUBECTL) apply -k operator/config/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests kubectl
$(KUBECTL) apply -k operator/config/default
# Generate manifests e.g. CRD, Webhooks
manifests: controller-gen
$(CONTROLLER_GEN) crd rbac:roleName=manager-role webhook paths="./pkg/apis/..." output:dir=operator/config/crd/bases
# Run go fmt against code
fmt:
go fmt ./pkg/... ./cmd/...
# Run go vet against code
vet:
go vet ./pkg/... ./cmd/...
# Run go mod tidy against code
tidy:
go mod tidy
# Run go mod vendor against code
vendor:
go mod vendor
# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="./hack/boilerplate.go.txt" paths="./pkg/apis/..."
generate-verify: generate
./hack/verify-generate.sh
build-controller-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run cmd/forklift-controller:forklift-controller-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-controller-image: build-controller-image
$(CONTAINER_CMD) tag bazel/cmd/forklift-controller:forklift-controller-image $(CONTROLLER_IMAGE)
$(CONTAINER_CMD) push $(CONTROLLER_IMAGE)
build-api-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run cmd/forklift-api:forklift-api-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-api-image: build-api-image
$(CONTAINER_CMD) tag bazel/cmd/forklift-api:forklift-api-image $(API_IMAGE)
$(CONTAINER_CMD) push $(API_IMAGE)
build-validation-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run validation:forklift-validation-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-validation-image: build-validation-image
$(CONTAINER_CMD) tag bazel/validation:forklift-validation-image $(VALIDATION_IMAGE)
$(CONTAINER_CMD) push $(VALIDATION_IMAGE)
build-operator-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run operator:forklift-operator-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-operator-image: build-operator-image
$(CONTAINER_CMD) tag bazel/operator:forklift-operator-image $(OPERATOR_IMAGE)
$(CONTAINER_CMD) push $(OPERATOR_IMAGE)
build-virt-v2v-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run --package_path=virt-v2v/cold forklift-virt-v2v \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-virt-v2v-image: build-virt-v2v-image
$(CONTAINER_CMD) tag bazel:forklift-virt-v2v $(VIRT_V2V_IMAGE)
$(CONTAINER_CMD) push $(VIRT_V2V_IMAGE)
build-virt-v2v-warm-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run --package_path=virt-v2v/warm forklift-virt-v2v-warm \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-virt-v2v-warm-image: build-virt-v2v-warm-image
$(CONTAINER_CMD) tag bazel:forklift-virt-v2v-warm ${VIRT_V2V_WARM_IMAGE}
$(CONTAINER_CMD) push ${VIRT_V2V_WARM_IMAGE}
build-operator-bundle-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run operator:forklift-operator-bundle-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD) \
--action_env VERSION=$(VERSION) \
--action_env NAMESPACE=$(NAMESPACE) \
--action_env CHANNELS=$(CHANNELS) \
--action_env DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) \
--action_env OPERATOR_IMAGE=$(OPERATOR_IMAGE) \
--action_env MUST_GATHER_IMAGE=$(MUST_GATHER_IMAGE) \
--action_env MUST_GATHER_API_IMAGE=$(MUST_GATHER_API_IMAGE) \
--action_env UI_IMAGE=$(UI_IMAGE) \
--action_env UI_PLUGIN_IMAGE=$(UI_PLUGIN_IMAGE) \
--action_env VALIDATION_IMAGE=$(VALIDATION_IMAGE) \
--action_env VIRT_V2V_IMAGE=$(VIRT_V2V_IMAGE) \
--action_env VIRT_V2V_WARM_IMAGE=$(VIRT_V2V_WARM_IMAGE) \
--action_env CONTROLLER_IMAGE=$(CONTROLLER_IMAGE) \
--action_env API_IMAGE=$(API_IMAGE) \
--action_env POPULATOR_CONTROLLER_IMAGE=$(POPULATOR_CONTROLLER_IMAGE) \
--action_env OVIRT_POPULATOR_IMAGE=$(OVIRT_POPULATOR_IMAGE) \
--action_env OPENSTACK_POPULATOR_IMAGE=$(OPENSTACK_POPULATOR_IMAGE)\
--action_env OVA_PROVIDER_SERVER_IMAGE=$(OVA_PROVIDER_SERVER_IMAGE)
push-operator-bundle-image: build-operator-bundle-image
$(CONTAINER_CMD) tag bazel/operator:forklift-operator-bundle-image $(OPERATOR_BUNDLE_IMAGE)
$(CONTAINER_CMD) push $(OPERATOR_BUNDLE_IMAGE)
build-operator-index-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run operator:forklift-operator-index-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD) \
--action_env VERSION=$(VERSION) \
--action_env CHANNELS=$(CHANNELS) \
--action_env DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) \
--action_env OPT_OPTS=$(OPM_OPTS) \
--action_env REGISTRY=$(REGISTRY) \
--action_env REGISTRY_TAG=$(REGISTRY_TAG) \
--action_env REGISTRY_ACCOUNT=$(REGISTRY_ACCOUNT)
push-operator-index-image: build-operator-index-image
$(CONTAINER_CMD) tag bazel/operator:forklift-operator-index-image $(OPERATOR_INDEX_IMAGE)
$(CONTAINER_CMD) push $(OPERATOR_INDEX_IMAGE)
build-populator-controller-image: check_container_runtmime
export CONTAINER_CMD=$(CONTAINER_CMD); \
bazel run cmd/populator-controller:populator-controller-image \
$(BAZEL_OPTS) \
--action_env CONTAINER_CMD=$(CONTAINER_CMD)
push-populator-controller-image: build-populator-controller-image
$(CONTAINER_CMD) tag bazel/cmd/populator-controller:populator-controller-image $(POPULATOR_CONTROLLER_IMAGE)
$(CONTAINER_CMD) push $(POPULATOR_CONTROLLER_IMAGE)
# Build the docker image
build-ovirt-populator-image:
$(CONTAINER_CMD) build -f hack/ovirt-populator/Containerfile -t $(OVIRT_POPULATOR_IMAGE) .
# Push the docker image
push-ovirt-populator-image: build-ovirt-populator-image
$(CONTAINER_CMD) push $(OVIRT_POPULATOR_IMAGE)
build-openstack-populator-image: check_container_runtmime
$(CONTAINER_CMD) build -f hack/openstack-populator/Containerfile -t $(OPENSTACK_POPULATOR_IMAGE) .
push-openstack-populator-image: build-openstack-populator-image
$(CONTAINER_CMD) push $(OPENSTACK_POPULATOR_IMAGE)
build-ova-provider-server-image: check_container_runtmime
$(CONTAINER_CMD) build -f hack/ova-provider-server/Containerfile -t $(OVA_PROVIDER_SERVER_IMAGE) .
push-ova-provider-server-image: build-ova-provider-server-image
$(CONTAINER_CMD) push $(OVA_PROVIDER_SERVER_IMAGE)
build-all-images: build-api-image \
build-controller-image \
build-validation-image \
build-operator-image \
build-virt-v2v-image \
build-virt-v2v-warm-image \
build-operator-bundle-image \
build-operator-index-image \
build-populator-controller-image \
build-ovirt-populator-image \
build-openstack-populator-image\
build-ova-provider-server-image
push-all-images: push-api-image \
push-controller-image \
push-validation-image \
push-operator-image \
push-virt-v2v-image \
push-virt-v2v-warm-image \
push-operator-bundle-image \
push-operator-index-image \
push-populator-controller-image \
push-ovirt-populator-image \
push-openstack-populator-image\
push-ova-provider-server-image
.PHONY: check_container_runtmime
check_container_runtmime:
@if [ ! -x "$(CONTAINER_CMD)" ]; then \
echo "Container runtime was not automatically detected"; \
echo "Please install podman or docker and make sure it's available in PATH"; \
exit 1; \
fi
bazel-generate:
bazel run //:gazelle
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN)
$(DEFAULT_CONTROLLER_GEN):
go install sigs.k8s.io/controller-tools/cmd/[email protected]
.PHONY: kubectl
kubectl: $(KUBECTL)
$(DEFAULT_KUBECTL):
curl -L https://dl.k8s.io/release/v1.25.10/bin/linux/amd64/kubectl -o $(GOBIN)/kubectl && chmod +x $(GOBIN)/kubectl