forked from kosmos-io/netdoctor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (115 loc) · 3.47 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
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
VERSION ?= '$(shell hack/version.sh)'
# Images management
REGISTRY?="ghcr.io/kosmos-io"
REGISTRY_USER_NAME?=""
REGISTRY_PASSWORD?=""
REGISTRY_SERVER_ADDRESS?=""
KIND_IMAGE_TAG?="v1.25.3"
TARGETS := clusterlink-floater \
CTL_TARGETS := netctl
# Build code.
#
# Args:
# GOOS: OS to build.
# GOARCH: Arch to build.
#
# Example:
# make
# make all
# make clusterlink-controller-manager
# make clusterlink-controller-manager 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-clusterlink-controller-manager
# make image-clusterlink-controller-manager 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-clusterlink-controller-manager
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: test
test:
mkdir -p ./_output/coverage/
go test --race --v ./pkg/... -coverprofile=./_output/coverage/coverage_pkg.txt -covermode=atomic
go test --race --v ./cmd/... -coverprofile=./_output/coverage/coverage_cmd.txt -covermode=atomic
upload-images: images
@echo "push images to $(REGISTRY)"
docker push ${REGISTRY}/clusterlink-controller-manager:${VERSION}
docker push ${REGISTRY}/kosmos-operator:${VERSION}
docker push ${REGISTRY}/clusterlink-agent:${VERSION}
docker push ${REGISTRY}/clusterlink-proxy:${VERSION}
docker push ${REGISTRY}/clusterlink-network-manager:${VERSION}
docker push ${REGISTRY}/clusterlink-floater:${VERSION}
docker push ${REGISTRY}/clusterlink-elector:${VERSION}
docker push ${REGISTRY}/clustertree-cluster-manager:${VERSION}
docker push ${REGISTRY}/scheduler:${VERSION}
.PHONY: release
release:
@make release-netctl GOOS=linux GOARCH=amd64
@make release-netctl GOOS=linux GOARCH=arm64
@make release-netctl GOOS=darwin GOARCH=amd64
@make release-netctl GOOS=darwin GOARCH=arm64
release-netctl:
hack/release.sh netctl ${GOOS} ${GOARCH}
.PHONY: lint
lint: golangci-lint
$(GOLANGLINT_BIN) run
.PHONY: lint-fix
lint-fix: golangci-lint
$(GOLANGLINT_BIN) run --fix
golangci-lint:
ifeq (, $(shell which golangci-lint))
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/[email protected]
GOLANGLINT_BIN=$(shell go env GOPATH)/bin/golangci-lint
else
GOLANGLINT_BIN=$(shell which golangci-lint)
endif
image-base-kind-builder:
docker buildx build \
-t $(REGISTRY)/node:$(KIND_IMAGE_TAG) \
--platform=linux/amd64,linux/arm64 \
--push \
-f cluster/images/buildx.kind.Dockerfile .