forked from kubevirt/cluster-network-addons-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
230 lines (177 loc) · 5.82 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
all: fmt check
VERSION ?= 99.0.0
export VERSION := $(VERSION)
# Always keep the last released version here
VERSION_REPLACES ?= 0.65.1
DEPLOY_DIR ?= manifests
IMAGE_REGISTRY ?= quay.io/kubevirt
IMAGE_TAG ?= latest
OPERATOR_IMAGE ?= cluster-network-addons-operator
REGISTRY_IMAGE ?= cluster-network-addons-registry
TARGETS = \
gen-k8s \
gen-k8s-check \
goimports \
goimports-check \
vet \
whitespace \
whitespace-check
export GOFLAGS=-mod=vendor
export GO111MODULE=on
WHAT ?= ./pkg ./cmd ./tools/
GINKGO_EXTRA_ARGS ?=
GINKGO_ARGS ?= --v -r --progress $(GINKGO_EXTRA_ARGS)
GINKGO ?= build/_output/bin/ginkgo
export E2E_TEST_TIMEOUT ?= 3h
E2E_TEST_EXTRA_ARGS ?=
E2E_TEST_ARGS ?= $(strip -test.v -test.timeout $(E2E_TEST_TIMEOUT) -ginkgo.v $(E2E_TEST_EXTRA_ARGS))
E2E_SUITES = \
test/e2e/lifecycle \
test/e2e/workflow
BIN_DIR = $(CURDIR)/build/_output/bin/
export GOROOT=$(BIN_DIR)/go/
export GOBIN = $(GOROOT)/bin/
export PATH := $(GOBIN):$(PATH)
OPERATOR_SDK ?= $(BIN_DIR)/operator-sdk
GITHUB_RELEASE ?= $(BIN_DIR)/github-release
GO := $(GOBIN)/go
$(GO):
hack/install-go.sh $(BIN_DIR)
$(GINKGO): $(GO) go.mod
GOBIN=$$(pwd)/build/_output/bin/ $(GO) install ./vendor/github.com/onsi/ginkgo/ginkgo
$(OPERATOR_SDK): $(GO) go.mod
GOBIN=$$(pwd)/build/_output/bin/ $(GO) install ./vendor/github.com/operator-framework/operator-sdk/cmd/operator-sdk
$(GITHUB_RELEASE): $(GO) go.mod
GOBIN=$$(pwd)/build/_output/bin/ $(GO) install ./vendor/github.com/github-release/github-release
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
# Gather needed source files and directories to create target dependencies
directories := $(filter-out ./ ./vendor/ ,$(sort $(dir $(wildcard ./*/))))
all_sources=$(call rwildcard,$(directories),*) $(filter-out $(TARGETS), $(wildcard *))
cmd_sources=$(call rwildcard,cmd/,*.go)
pkg_sources=$(call rwildcard,pkg/,*.go)
apis_sources=$(call rwildcard,pkg/apis,*.go)
fmt: whitespace goimports
goimports: $(cmd_sources) $(pkg_sources)
$(GO) run ./vendor/golang.org/x/tools/cmd/goimports -w ./pkg ./cmd ./test/ ./tools/
touch $@
whitespace: $(all_sources)
./hack/whitespace.sh --fix
touch $@
check: whitespace-check vet goimports-check gen-k8s-check test/unit prom-rules-verify
./hack/check.sh
whitespace-check: $(all_sources)
./hack/whitespace.sh
touch $@
vet: $(GO) $(cmd_sources) $(pkg_sources)
$(GO) vet ./pkg/... ./cmd/... ./test/... ./tools/...
touch $@
goimports-check: $(GO) $(cmd_sources) $(pkg_sources)
$(GO) run ./vendor/golang.org/x/tools/cmd/goimports -d ./pkg ./cmd
touch $@
test/unit: $(GINKGO)
$(GINKGO) $(GINKGO_ARGS) $(WHAT)
manager: $(GO)
CGO_ENABLED=0 GOOS=linux $(GO) build -o $(BIN_DIR)/$@ ./cmd/...
manifest-templator: $(GO)
CGO_ENABLED=0 GOOS=linux $(GO) build -o $(BIN_DIR)/$@ ./tools/manifest-templator/...
docker-build: docker-build-operator docker-build-registry
docker-build-operator: manager manifest-templator
docker build -f build/operator/Dockerfile -t $(IMAGE_REGISTRY)/$(OPERATOR_IMAGE):$(IMAGE_TAG) .
docker-build-registry:
docker build -f build/registry/Dockerfile -t $(IMAGE_REGISTRY)/$(REGISTRY_IMAGE):$(IMAGE_TAG) .
docker-push: docker-push-operator docker-push-registry
docker-push-operator:
docker push $(IMAGE_REGISTRY)/$(OPERATOR_IMAGE):$(IMAGE_TAG)
docker-push-registry:
docker push $(IMAGE_REGISTRY)/$(REGISTRY_IMAGE):$(IMAGE_TAG)
prom-rules-verify:
hack/prom-rule-ci/verify-rules.sh \
data/monitoring/prom-rule.yaml \
hack/prom-rule-ci/prom-rules-tests.yaml
cluster-up:
./cluster/up.sh
cluster-down:
./cluster/down.sh
cluster-sync: cluster-operator-push cluster-operator-install
cluster-operator-push:
./cluster/operator-push.sh
cluster-operator-install:
./cluster/operator-install.sh
$(E2E_SUITES): $(OPERATOR_SDK)
unset GOFLAGS && OPERATOR_SDK=$(OPERATOR_SDK) TEST_SUITE=$@ TEST_ARGS="$(E2E_TEST_ARGS)" ./hack/functest.sh
cluster-clean:
./cluster/clean.sh
# Default images can be found in pkg/components/components.go
gen-manifests: manifest-templator
VERSION_REPLACES=$(VERSION_REPLACES) \
DEPLOY_DIR=$(DEPLOY_DIR) \
CONTAINER_PREFIX=$(IMAGE_REGISTRY) \
CONTAINER_TAG=$(IMAGE_TAG) \
MULTUS_IMAGE=$(MULTUS_IMAGE) \
LINUX_BRIDGE_CNI_IMAGE=$(LINUX_BRIDGE_CNI_IMAGE) \
KUBEMACPOOL_IMAGE=$(KUBEMACPOOL_IMAGE) \
MACVTAP_CNI_IMAGE=$(MACVTAP_CNI_IMAGE) \
./hack/generate-manifests.sh
gen-k8s: $(OPERATOR_SDK) $(apis_sources)
$(OPERATOR_SDK) generate k8s
touch $@
gen-k8s-check: $(apis_sources)
./hack/verify-codegen.sh
touch $@
bump-kubevirtci:
rm -rf _kubevirtci
./hack/bump-kubevirtci.sh
prepare-patch:
./hack/prepare-release.sh patch
prepare-minor:
./hack/prepare-release.sh minor
prepare-major:
./hack/prepare-release.sh major
release: $(GITHUB_RELEASE)
DESCRIPTION=version/description \
GITHUB_RELEASE=$(GITHUB_RELEASE) \
TAG=v$(shell hack/version.sh) \
hack/release.sh \
manifests/cluster-network-addons/cluster-network-addons.package.yaml \
$(shell find manifests/cluster-network-addons/$(shell hack/version.sh) -type f)
vendor: $(GO)
$(GO) mod tidy
$(GO) mod vendor
auto-bumper: $(GO)
PUSH_IMAGES=true $(GO) run $(shell ls tools/bumper/*.go | grep -v test) ${ARGS}
bump-%:
CNAO_VERSION=${VERSION} ./hack/components/bump-$*.sh
bump-all: bump-nmstate bump-kubemacpool bump-macvtap-cni bump-linux-bridge bump-multus bump-ovs-cni bump-bridge-marker
.PHONY: \
$(E2E_SUITES) \
all \
check \
cluster-clean \
cluster-down \
cluster-operator-install \
cluster-operator-push \
cluster-sync \
cluster-up \
manager \
manifests-templator \
docker-build \
docker-build-operator \
docker-build-registry \
docker-push \
docker-push-operator \
docker-push-registry \
gen-manifests \
bump-all \
test/unit \
bump-kubevirtci \
prepare-patch \
prepare-minor \
prepare-major \
vendor \
auto-bumper \
bump-% \
bump-all \
gen-k8s \
prom-rules-verify \
release