forked from alibaba/kt-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (53 loc) · 2.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
PREFIX ?= registry.cn-hangzhou.aliyuncs.com/rdc-incubator
TAG ?= $(shell date +%s)
SHADOW_IMAGE = kt-connect-shadow
SHADOW_BASE_IMAGE = shadow-base
BUILDER_IMAGE = builder
DASHBOARD_IMAGE = kt-connect-dashboard
SERVER_IMAGE = kt-connect-server
# generate mock
generate-mock:
echo "generate mocks"
mockgen -source=pkg/kt/cluster/types.go -destination=pkg/kt/cluster/mock.go -package=cluster
mockgen -source=pkg/kt/command/types.go -destination=pkg/kt/command/mock.go -package=command
mockgen -source=pkg/kt/connect/types.go -destination=pkg/kt/connect/mock.go -package=connect
mockgen -source=pkg/kt/exec/kubectl/types.go -destination=pkg/kt/exec/kubectl/mock.go -package=kubectl
mockgen -source=pkg/kt/exec/portforward/types.go -destination=pkg/kt/exec/portforward/mock.go -package=portforward
mockgen -source=pkg/kt/exec/ssh/types.go -destination=pkg/kt/exec/ssh/mock.go -package=ssh
mockgen -source=pkg/kt/exec/sshchannel/types.go -destination=pkg/kt/exec/sshchannel/mock.go -package=sshchannel
mockgen -source=pkg/kt/exec/sshuttle/types.go -destination=pkg/kt/exec/sshuttle/mock.go -package=sshuttle
mockgen -source=pkg/kt/exec/types.go -destination=pkg/kt/exec/mock.go -package=exec
mockgen -source=pkg/kt/exec/tunnel/types.go -destination=pkg/kt/exec/tunnel/mock.go -package=tunnel
mockgen -source=pkg/kt/types.go -destination=pkg/kt/mock.go -package=kt
# run unit test
test:
mkdir -p artifacts/report/coverage
go test -v -cover -coverprofile c.out.tmp ./...
cat c.out.tmp | grep -v "_mock.go" > c.out
go tool cover -html=c.out -o artifacts/report/coverage/index.html
# build kt project
compile:
goreleaser --snapshot --skip-publish --rm-dist
# check the style
check:
golint ./pkg/... ./cmd/...
# golangci-lint run ./pkg/...
# build this image before shadow
build-shadow-base:
docker build -t $(PREFIX)/$(SHADOW_BASE_IMAGE):$(TAG) -f build/docker/shadow/Dockerfile_base .
# build shadow
build-shadow:
GOARCH=amd64 GOOS=linux go build -gcflags "all=-N -l" -o artifacts/shadow/shadow-linux-amd64 cmd/shadow/main.go
docker build -t $(PREFIX)/$(SHADOW_IMAGE):$(TAG) -f build/docker/shadow/Dockerfile .
# dlv for debug
build-shadow-dlv:
make build-shadow TAG=latest
scripts/build-shadow-dlv
build-dashboard: build-frontend
build-frontend:
docker build -t $(PREFIX)/$(DASHBOARD_IMAGE):$(TAG) -f build/docker/dashboard/Dockerfile .
release-dashboard:
docker push $(PREFIX)/$(DASHBOARD_IMAGE):$(TAG)
docker push $(PREFIX)/$(SERVER_IMAGE):$(TAG)
clean:
rm -fr artifacts