forked from kubevirt/cluster-network-addons-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
152 lines (116 loc) · 3.89 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
all: fmt check
# Always keep the future version here, so we won't overwrite latest released manifests
VERSION ?= 0.24.0
export VERSION := $(VERSION)
# Always keep the last released version here
VERSION_REPLACES ?= 0.23.0
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
GINKGO_EXTRA_ARGS ?=
GINKGO_ARGS ?= --v -r --progress $(GINKGO_EXTRA_ARGS)
GINKGO ?= build/_output/bin/ginkgo
E2E_TEST_EXTRA_ARGS ?=
E2E_TEST_ARGS ?= $(strip -test.v -test.timeout 2h -ginkgo.v $(E2E_TEST_EXTRA_ARGS))
E2E_SUITES = \
test/e2e/lifecycle \
test/e2e/workflow
OPERATOR_SDK ?= build/_output/bin/operator-sdk
$(GINKGO): Gopkg.toml
GOBIN=$$(pwd)/build/_output/bin/ go install ./vendor/github.com/onsi/ginkgo/ginkgo
$(OPERATOR_SDK): Gopkg.toml
GOBIN=$$(pwd)/build/_output/bin/ go install ./vendor/github.com/operator-framework/operator-sdk/cmd/operator-sdk
# 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/
touch $@
whitespace: $(all_sources)
./hack/whitespace.sh --fix
touch $@
check: whitespace-check vet goimports-check gen-k8s-check test/unit
whitespace-check: $(all_sources)
./hack/whitespace.sh
touch $@
vet: $(cmd_sources) $(pkg_sources)
go vet ./pkg/... ./cmd/... ./test/...
touch $@
goimports-check: $(cmd_sources) $(pkg_sources)
go run ./vendor/golang.org/x/tools/cmd/goimports -d ./pkg ./cmd
touch $@
test/unit: $(GINKGO)
$(GINKGO) $(GINKGO_ARGS) ./pkg/ ./cmd/
docker-build: docker-build-operator docker-build-registry
docker-build-operator:
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)
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)
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:
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) \
./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 $@
.PHONY: \
$(E2E_SUITES) \
all \
check \
cluster-clean \
cluster-down \
cluster-operator-install \
cluster-operator-push \
cluster-sync \
cluster-up \
docker-build \
docker-build-operator \
docker-build-registry \
docker-push \
docker-push-operator \
docker-push-registry \
gen-manifests \
test/unit