-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathMakefile
More file actions
422 lines (324 loc) · 14.6 KB
/
Copy pathMakefile
File metadata and controls
422 lines (324 loc) · 14.6 KB
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
QUAY_USERNAME ?=
QUAY_PASSWORD ?=
SOURCE_DIRS = cmd pkg
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*")
SHA := $(shell git describe --no-match --always --abbrev=40 --dirty)
IMAGE_REGISTRY ?= quay.io
REGISTRY_NAMESPACE ?= kubevirt
IMAGE_TAG ?= latest
OPERATOR_IMAGE ?= $(REGISTRY_NAMESPACE)/hyperconverged-cluster-operator
WEBHOOK_IMAGE ?= $(REGISTRY_NAMESPACE)/hyperconverged-cluster-webhook
FUNC_TEST_IMAGE ?= $(REGISTRY_NAMESPACE)/hyperconverged-cluster-functest
VIRT_ARTIFACTS_SERVER ?= $(REGISTRY_NAMESPACE)/virt-artifacts-server
BUNDLE_IMAGE ?= $(REGISTRY_NAMESPACE)/hyperconverged-cluster-bundle
INDEX_IMAGE ?= $(REGISTRY_NAMESPACE)/hyperconverged-cluster-index
BUILDER_IMAGE ?= $(REGISTRY_NAMESPACE)/hco-builder
BUILDER_IMAGE_TAG ?= latest
LDFLAGS ?= -w -s
GOLANDCI_LINT_VERSION ?= v2.12.2
HCO_BUMP_LEVEL ?= minor
ASSETS_DIR ?= assets
DUMP_NETWORK_POLICIES ?= "false"
UNAME_ARCH := $(shell uname -m)
ifeq ($(UNAME_ARCH),x86_64)
TEMP_ARCH = amd64
else ifeq ($(UNAME_ARCH),aarch64)
TEMP_ARCH = arm64
else
TEMP_ARCH := $(UNAME_ARCH)
endif
INSTALLATION_NAMESPACE ?= kubevirt-hyperconverged
ARCH ?= $(TEMP_ARCH)
# Prow doesn't have docker command
DO=./hack/in-docker.sh
ifeq (, $(shell (which docker 2> /dev/null || which podman 2> /dev/null)))
DO=eval
export JOB_TYPE=prow
endif
sanity: generate gogenerate generate-crd generate-crd-for-csv go-fix generate-doc validate-no-offensive-lang goimport lint-metrics lint-monitoring update-kv-fg-file
go version
go fmt ./...
go mod tidy -v
go mod vendor
make build-manifests
git add -N vendor
git difftool -y --trust-exit-code --extcmd=./hack/diff-csv.sh
goimport:
go install golang.org/x/tools/cmd/goimports@latest
goimports -w -local="kubevirt.io,github.com/kubevirt,github.com/kubevirt/hyperconverged-cluster-operator" $(shell find . -type f -name '*.go' ! -path "*/vendor/*" ! -path "./_kubevirtci/*" ! -path "*zz_generated*" )
update-kv-fg-file:
./hack/update-kv-fg-file.sh
lint:
GOTOOLCHAIN=go1.26.3 go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANDCI_LINT_VERSION}
golangci-lint run
build: build-operator build-csv-merger build-webhook
build-operator: $(SOURCES) ## Build binary from source
go build -ldflags="${LDFLAGS}" -o _out/hyperconverged-cluster-operator ./cmd/hyperconverged-cluster-operator
build-csv-merger: generate-crd-for-csv ## Build binary from source
go build -ldflags="${LDFLAGS}" -o _out/csv-merger ./tools/csv-merger
build-manifest-templator: ## Build binary from source
go build -ldflags="${LDFLAGS}" -o _out/manifest-templator ./tools/manifest-templator
generate-feature-gates: sort-feature-gates
cd api/v1beta1 && go generate .
go build -o _out/fg-v1-comments ./tools/fg-v1-comments
./_out/fg-v1-comments
sort-feature-gates:
jq 'sort_by((if .phase == "beta" then 0 elif .phase == "alpha" then 1 else 2 end), .name)' pkg/featuregatedetails/feature-gates.json > pkg/featuregatedetails/feature-gates.temp
mv pkg/featuregatedetails/feature-gates.temp pkg/featuregatedetails/feature-gates.json
build-crd-creator: # this should run from a builder image. and so it assumes that everything is pre generated
go build -ldflags="${LDFLAGS}" -o _out/crd-creator ./tools/crd-creator
build-manifest-splitter:
go build -ldflags="${LDFLAGS}" -o _out/manifest-splitter ./tools/manifest-splitter
build-webhook: $(SOURCES) ## Build binary from source
go build -ldflags="${LDFLAGS}" -o _out/hyperconverged-cluster-webhook ./cmd/hyperconverged-cluster-webhook
build-manifests: generate-crd generate-crd-for-csv build-csv-merger build-manifest-splitter build-manifest-templator
DUMP_NETWORK_POLICIES=$(DUMP_NETWORK_POLICIES) ./hack/build-manifests.sh
build-manifests-prev:
RELEASE_DELTA=1 make build-manifests
build-prom-spec-dumper: ## Build binary from source
go build -ldflags="${LDFLAGS}" -o _out/rule-spec-dumper ./hack/prom-rule-ci/rule-spec-dumper.go
current-dir := $(realpath .)
prom-rules-verify: build-prom-spec-dumper
./hack/prom-rule-ci/verify-rules.sh \
"${current-dir}/_out/rule-spec-dumper" \
"${current-dir}/hack/prom-rule-ci"
install:
go install ./cmd/...
clean: ## Clean up the working environment
@rm -rf _out/
start:
./hack/deploy.sh
quay-token:
@./tools/token.sh $(QUAY_USERNAME) $(QUAY_PASSWORD)
bundle-push: container-build-operator-courier
@QUAY_USERNAME=$(QUAY_USERNAME) QUAY_PASSWORD=$(QUAY_PASSWORD) ./tools/operator-courier/push.sh
hack-clean: ## Run ./hack/clean.sh
./hack/clean.sh
container-build: container-build-operator container-build-webhook container-build-operator-courier container-build-functest container-build-artifacts-server
build-push-multi-arch-images: build-push-multi-arch-operator-image build-push-multi-arch-webhook-image build-push-multi-arch-functest-image build-push-multi-arch-artifacts-server
container-build-operator: gogenerate generate-crd-for-csv
. "hack/cri-bin.sh" && $$CRI_BIN build --platform=linux/$(ARCH) -f build/Dockerfile -t $(IMAGE_REGISTRY)/$(OPERATOR_IMAGE):$(IMAGE_TAG) --build-arg git_sha=$(SHA) .
build-push-multi-arch-operator-image: gogenerate generate-crd-for-csv
IMAGE_NAME=$(IMAGE_REGISTRY)/$(OPERATOR_IMAGE):$(IMAGE_TAG) SHA=SHA DOCKER_FILE=build/Dockerfile ./hack/build-push-multi-arch-images.sh
container-build-webhook:
. "hack/cri-bin.sh" && $$CRI_BIN build --platform=linux/$(ARCH) -f build/Dockerfile.webhook -t $(IMAGE_REGISTRY)/$(WEBHOOK_IMAGE):$(IMAGE_TAG) --build-arg git_sha=$(SHA) .
build-push-multi-arch-webhook-image:
IMAGE_NAME=$(IMAGE_REGISTRY)/$(WEBHOOK_IMAGE):$(IMAGE_TAG) SHA=$(SHA) DOCKER_FILE="build/Dockerfile.webhook" ./hack/build-push-multi-arch-images.sh
container-build-operator-courier:
podman build -f tools/operator-courier/Dockerfile -t hco-courier .
container-build-validate-bundles:
podman build -f tools/operator-sdk-validate/Dockerfile -t operator-sdk-validate-hco .
container-build-functest:
. "hack/cri-bin.sh" && $$CRI_BIN build --platform=linux/$(ARCH) -f build/Dockerfile.functest -t $(IMAGE_REGISTRY)/$(FUNC_TEST_IMAGE):$(IMAGE_TAG) --build-arg git_sha=$(SHA) .
build-push-multi-arch-functest-image:
IMAGE_NAME=$(IMAGE_REGISTRY)/$(FUNC_TEST_IMAGE):$(IMAGE_TAG) SHA=$(SHA) DOCKER_FILE="build/Dockerfile.functest" ./hack/build-push-multi-arch-images.sh
container-build-artifacts-server:
podman build -f build/Dockerfile.artifacts -t $(IMAGE_REGISTRY)/$(VIRT_ARTIFACTS_SERVER):$(IMAGE_TAG) --build-arg git_sha=$(SHA) .
build-push-multi-arch-artifacts-server:
IMAGE_NAME=$(IMAGE_REGISTRY)/$(VIRT_ARTIFACTS_SERVER):$(IMAGE_TAG) SHA=$(SHA) DOCKER_FILE="build/Dockerfile.artifacts" ./hack/build-push-multi-arch-images.sh
container-push: container-push-operator container-push-webhook container-push-functest container-push-artifacts-server
quay-login:
podman login $(IMAGE_REGISTRY) -u $(QUAY_USERNAME) -p "$(QUAY_PASSWORD)"
container-push-operator:
. "hack/cri-bin.sh" && $$CRI_BIN push $$CRI_INSECURE $(IMAGE_REGISTRY)/$(OPERATOR_IMAGE):$(IMAGE_TAG)
container-push-webhook:
. "hack/cri-bin.sh" && $$CRI_BIN push $$CRI_INSECURE $(IMAGE_REGISTRY)/$(WEBHOOK_IMAGE):$(IMAGE_TAG)
container-push-functest:
. "hack/cri-bin.sh" && $$CRI_BIN push $$CRI_INSECURE $(IMAGE_REGISTRY)/$(FUNC_TEST_IMAGE):$(IMAGE_TAG)
container-push-artifacts-server:
. "hack/cri-bin.sh" && $$CRI_BIN push $(IMAGE_REGISTRY)/$(VIRT_ARTIFACTS_SERVER):$(IMAGE_TAG)
retag-push-all-images:
IMAGE_REPO=$(IMAGE_REGISTRY)/$(OPERATOR_IMAGE) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(NEW_TAG) ./hack/retag-multi-arch-images.sh
IMAGE_REPO=$(IMAGE_REGISTRY)/$(WEBHOOK_IMAGE) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(NEW_TAG) ./hack/retag-multi-arch-images.sh
IMAGE_REPO=$(IMAGE_REGISTRY)/$(FUNC_TEST_IMAGE) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(NEW_TAG) ./hack/retag-multi-arch-images.sh
IMAGE_REPO=$(IMAGE_REGISTRY)/$(VIRT_ARTIFACTS_SERVER) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(NEW_TAG) ./hack/retag-multi-arch-images.sh
IMAGE_REPO=$(IMAGE_REGISTRY)/$(BUNDLE_IMAGE) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(NEW_TAG) ./hack/retag-multi-arch-images.sh
IMAGE_REPO=$(IMAGE_REGISTRY)/$(INDEX_IMAGE) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(NEW_TAG) ./hack/retag-multi-arch-images.sh
cluster-up:
./cluster/up.sh
cluster-down:
./cluster/down.sh
cluster-sync:
IMAGE_REGISTRY=$(IMAGE_REGISTRY) REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) ./cluster/sync.sh
cluster-redeploy-operator:
IMAGE_REGISTRY=$(IMAGE_REGISTRY) REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) ./cluster/sync-pod.sh operator
cluster-redeploy-webhook:
IMAGE_REGISTRY=$(IMAGE_REGISTRY) REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) ./cluster/sync-pod.sh webhook
cluster-clean:
CMD="./cluster/kubectl.sh" ./hack/clean.sh
ci-functest: build-functest test-functional
functest: test-functional-in-container
build-functest:
${DO} ./hack/build-tests.sh
test-functional:
JOB_TYPE="stdci" ./hack/run-tests.sh
test-functional-prow:
./hack/run-tests.sh
test-functional-in-container:
./hack/run-tests-in-container.sh
test-kv-smoke-prow:
./hack/kv-smoke-tests.sh
stageRegistry:
@APP_REGISTRY_NAMESPACE=redhat-operators-stage PACKAGE=kubevirt-hyperconverged ./tools/quay-registry.sh $(QUAY_USERNAME) $(QUAY_PASSWORD)
bundleRegistry:
REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) IMAGE_REGISTRY=$(IMAGE_REGISTRY) ./hack/build-registry-bundle.sh
container-clusterserviceversion:
REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) IMAGE_REGISTRY=$(IMAGE_REGISTRY) ./hack/upgrade-test-clusterserviceversion.sh
build-push-all: container-build-operator container-push-operator container-build-webhook container-push-webhook container-build-operator-courier bundle-push
upgrade-test:
./hack/upgrade-test.sh
upgrade-test-index-image:
./hack/upgrade-test-index-image.sh
upgrade-test-operator-sdk:
./hack/upgrade-test-operator-sdk.sh
consecutive-upgrades-test:
./hack/consecutive-upgrades-test.sh
kubevirt-nightly-test:
./hack/kubevirt-nightly-test.sh
dump-state:
./hack/dump-state.sh
bump-kubevirtci:
./hack/bump-kubevirtci.sh
gogenerate: generate
go generate ./pkg/upgradepatch
generate-crd: generate build-crd-creator
./_out/crd-creator --output-file=config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
@echo "the CRD file was generated in config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml"
cp config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml ./tools/manifest-templator/generated-crd.yaml
@echo "the CRD file was generated in tools/manifest-templator/generated-crd.yaml"
generate-crd-for-csv: build-crd-creator # this should run from a builder image. and so it assumes that everything is pre generated
./_out/crd-creator --output-file=./tools/csv-merger/generated-crd.yaml --webhook-name=hco-webhook --namespace=$(INSTALLATION_NAMESPACE)
@echo "the CRD file was generated in tools/csv-merger/generated-crd.yaml"
generate: generate-feature-gates
./hack/generate.sh
generate-doc: build-docgen
_out/docgen --in=./api/v1/hyperconverged_types.go --feature-gates=pkg/featuregatedetails/feature-gates.json > docs/api.md
_out/docgen --in=./api/v1beta1/hyperconverged_types.go > docs/api-v1beta1.md
_out/metricsdocs > docs/metrics.md
build-docgen:
go build -ldflags="${LDFLAGS}" -o _out/docgen ./tools/docgen
go build -ldflags="${LDFLAGS}" -o _out/metricsdocs ./tools/metricsdocs
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ''
test-unit: gogenerate generate-crd
./hack/unit-test.sh
test-unit-coverage: gogenerate generate-crd
./hack/unit-test-coverage.sh
test-fuzz-api-conversion: generate
go test -v ./api/v1beta1/ -run "FuzzV1beta1ToV1RoundTrip" -fuzz="FuzzV1beta1ToV1RoundTrip" -fuzztime=5s 2>&1
go test -v ./api/v1beta1/ -run "FuzzV1ToV1beta1RoundTrip" -fuzz="FuzzV1ToV1beta1RoundTrip" -fuzztime=5s 2>&1
test: test-unit
charts:
./hack/build-charts.sh
local:
./hack/make_local.sh
deploy_cr: deploy_hco_cr deploy_hpp deploy_fake_kubedescheduler
deploy_hco_cr:
./hack/deploy_only_cr.sh
deploy_hpp:
./hack/hpp/deploy_hpp.sh
deploy_fake_kubedescheduler:
./hack/kubeDescheduler/deploy_fake_kubedescheduler.sh
validate-no-offensive-lang:
./hack/validate-no-offensive-lang.sh
lint-metrics:
./hack/prom_metric_linter.sh --operator-name="kubevirt" --sub-operator-name="hco"
lint-monitoring:
go install github.com/kubevirt/monitoring/monitoringlinter/cmd/monitoringlinter@a697c0c
monitoringlinter ./api/... ./pkg/... ./controllers/...
go-fix:
./hack/go-fix.sh
bump-hco:
./hack/bump-hco.sh ${HCO_BUMP_LEVEL}
build-annotate-dicts:
go build -o ./_out/annotate-dicts ./tools/annotate-dicts/
annotate-dicts: build-annotate-dicts
ASSETS_DIR=$(ASSETS_DIR) ./hack/annotate-dicts.sh
create-builder-image:
IMAGE_NAME=$(IMAGE_REGISTRY)/$(BUILDER_IMAGE):$(IMAGE_TAG) ./hack/builder/create-builder-image.sh
retag-builder-image:
IMAGE_REPO=$(IMAGE_REGISTRY)/$(BUILDER_IMAGE) CURRENT_TAG=$(IMAGE_TAG) NEW_TAG=$(BUILDER_IMAGE_TAG) ./hack/retag-multi-arch-images.sh
# Temporary alias, until changing the usage of this target, from another repo
push-builder-image: retag-builder-image
.PHONY: start \
clean \
build \
build-operator \
build-csv-merger \
build-manifest-templator \
sort-feature-gates \
generate-feature-gates \
build-crd-creator \
build-manifest-splitter \
build-webhook \
build-manifests \
build-manifests-prev \
help \
hack-clean \
container-build \
container-build-operator \
container-build-webhook \
container-build-operator-courier \
container-build-validate-bundles \
container-build-functest \
container-build-artifacts-server \
container-push \
container-push-operator \
container-push-webhook \
container-push-functest \
container-push-artifacts-server \
cluster-up \
cluster-down \
cluster-sync \
cluster-redeploy-operator \
cluster-redeploy-webhook \
cluster-clean \
stageRegistry \
functest \
quay-token \
bundle-push \
build-push-all \
ci-functest \
build-functest \
test-functional \
test-functional-prow \
test-functional-in-container \
test-kv-smoke-prow \
test-unit \
test-unit-coverage \
charts \
kubevirt-nightly-test \
local \
deploy_cr \
deploy_fake_kubedescheduler \
build-docgen \
gogenerate \
generate \
generate-doc \
validate-no-offensive-lang \
lint-metrics \
lint-monitoring \
go-fix \
sanity \
goimport \
update-kv-fg-file \
bump-hco \
bump-kubevirtci \
build-push-multi-arch-operator-image \
build-push-multi-arch-webhook-image \
build-push-multi-arch-functest-image \
build-push-multi-arch-artifacts-server \
build-push-multi-arch-images \
retag-push-all-images \
build-annotate-dicts \
annotate-dicts \
create-builder-image \
push-builder-image \
retag-builder-image \
test-fuzz-api-conversion