forked from karmada-io/karmada
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
170 lines (149 loc) · 4.84 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
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
VERSION ?= '$(shell hack/version.sh)'
# Images management
REGISTRY?="docker.io/karmada"
REGISTRY_USER_NAME?=""
REGISTRY_PASSWORD?=""
REGISTRY_SERVER_ADDRESS?=""
TARGETS := karmada-aggregated-apiserver \
karmada-controller-manager \
karmada-scheduler \
karmada-descheduler \
karmada-webhook \
karmada-agent \
karmada-scheduler-estimator \
karmada-interpreter-webhook-example \
karmada-search \
karmada-operator \
karmada-metrics-adapter
CTL_TARGETS := karmadactl kubectl-karmada
# Build code.
#
# Args:
# GOOS: OS to build.
# GOARCH: Arch to build.
#
# Example:
# make
# make all
# make karmada-aggregated-apiserver
# make karmada-aggregated-apiserver GOOS=linux
CMD_TARGET=$(TARGETS) $(CTL_TARGETS)
.PHONY: all
all: $(CMD_TARGET)
.PHONY: $(CMD_TARGET)
$(CMD_TARGET):
BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh $@
# Build image.
#
# Args:
# GOARCH: Arch to build.
# OUTPUT_TYPE: Destination to save image(docker/registry).
#
# Example:
# make images
# make image-karmada-aggregated-apiserver
# make image-karmada-aggregated-apiserver GOARCH=arm64
IMAGE_TARGET=$(addprefix image-, $(TARGETS))
.PHONY: $(IMAGE_TARGET)
$(IMAGE_TARGET):
set -e;\
target=$$(echo $(subst image-,,$@));\
make $$target GOOS=linux;\
VERSION=$(VERSION) REGISTRY=$(REGISTRY) BUILD_PLATFORMS=linux/$(GOARCH) hack/docker.sh $$target
images: $(IMAGE_TARGET)
# Build and push multi-platform image to DockerHub
#
# Example
# make multi-platform-images
# make mp-image-karmada-aggregated-apiserver
MP_TARGET=$(addprefix mp-image-, $(TARGETS))
.PHONY: $(MP_TARGET)
$(MP_TARGET):
set -e;\
target=$$(echo $(subst mp-image-,,$@));\
make $$target GOOS=linux GOARCH=amd64;\
make $$target GOOS=linux GOARCH=arm64;\
VERSION=$(VERSION) REGISTRY=$(REGISTRY) \
OUTPUT_TYPE=registry \
BUILD_PLATFORMS=linux/amd64,linux/arm64 \
hack/docker.sh $$target
multi-platform-images: $(MP_TARGET)
.PHONY: clean
clean:
rm -rf _tmp _output
.PHONY: update
update:
hack/update-all.sh
.PHONY: verify
verify:
hack/verify-all.sh
.PHONY: package-chart
package-chart:
hack/package-helm-chart.sh $(VERSION)
.PHONY: push-chart
push-chart:
helm push _output/charts/karmada-chart-${VERSION}.tgz oci://docker.io/karmada
helm push _output/charts/karmada-operator-chart-${VERSION}.tgz oci://docker.io/karmada
GOTESTSUM_REGISTRY:=gotest.tools/gotestsum
GOTESTSUM_VERSION:=ec99a250836f069a524bb9d9b5de0a7a96334ea7 # v1.11.0
GOTESTSUM_FLAGS?=--format testname
GOTESTSUM_ENABLED?=
GOTEST=go test
.PHONY: install_gotestsum
install_gotestsum:
ifdef GOTESTSUM_ENABLED
go install ${GOTESTSUM_REGISTRY}@${GOTESTSUM_VERSION}
GOTEST=gotestsum ${GOTESTSUM_FLAGS} --
endif
.PHONY: test
test: GO_TEST_FLAGS ?= --race --v -covermode=atomic
test: install_gotestsum
mkdir -p ./_output/coverage/
$(GOTEST) $(GO_TEST_FLAGS) ./pkg/... -coverprofile=./_output/coverage/coverage_pkg.txt
$(GOTEST) $(GO_TEST_FLAGS) ./cmd/... -coverprofile=./_output/coverage/coverage_cmd.txt
$(GOTEST) $(GO_TEST_FLAGS) ./examples/... -coverprofile=./_output/coverage/coverage_examples.txt
$(GOTEST) $(GO_TEST_FLAGS) ./operator/... -coverprofile=./_output/coverage/coverage_operator.txt
upload-images: images
@echo "push images to $(REGISTRY)"
ifneq ($(REGISTRY_USER_NAME), "")
docker login -u ${REGISTRY_USER_NAME} -p ${REGISTRY_PASSWORD} ${REGISTRY_SERVER_ADDRESS}
endif
docker push ${REGISTRY}/karmada-controller-manager:${VERSION}
docker push ${REGISTRY}/karmada-scheduler:${VERSION}
docker push ${REGISTRY}/karmada-descheduler:${VERSION}
docker push ${REGISTRY}/karmada-webhook:${VERSION}
docker push ${REGISTRY}/karmada-agent:${VERSION}
docker push ${REGISTRY}/karmada-scheduler-estimator:${VERSION}
docker push ${REGISTRY}/karmada-interpreter-webhook-example:${VERSION}
docker push ${REGISTRY}/karmada-aggregated-apiserver:${VERSION}
docker push ${REGISTRY}/karmada-search:${VERSION}
docker push ${REGISTRY}/karmada-operator:${VERSION}
docker push ${REGISTRY}/karmada-metrics-adapter:${VERSION}
# Build and package binary
#
# Example
# make release-karmadactl
# make release-kubectl-karmada
# make release-kubectl-karmada GOOS=darwin GOARCH=amd64
RELEASE_TARGET=$(addprefix release-, $(CTL_TARGETS))
.PHONY: $(RELEASE_TARGET)
$(RELEASE_TARGET):
@set -e;\
target=$$(echo $(subst release-,,$@));\
make $$target;\
hack/release.sh $$target $(GOOS) $(GOARCH)
# Build and package binary for all platforms
#
# Example
# make release
release:
@make release-karmadactl GOOS=linux GOARCH=amd64
@make release-karmadactl GOOS=linux GOARCH=arm64
@make release-karmadactl GOOS=darwin GOARCH=amd64
@make release-karmadactl GOOS=darwin GOARCH=arm64
@make release-kubectl-karmada GOOS=linux GOARCH=amd64
@make release-kubectl-karmada GOOS=linux GOARCH=arm64
@make release-kubectl-karmada GOOS=darwin GOARCH=amd64
@make release-kubectl-karmada GOOS=darwin GOARCH=arm64