-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (86 loc) · 3.74 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
.PHONY: build
build: vendor-proto .generate .build
PHONY: .generate
.generate:
mkdir -p swagger
mkdir -p pkg/ocp-check-api
protoc -I vendor.protogen \
--go_out=pkg/ocp-check-api --go_opt=paths=import \
--go-grpc_out=pkg/ocp-check-api --go-grpc_opt=paths=import \
--grpc-gateway_out=pkg/ocp-check-api \
--grpc-gateway_opt=logtostderr=true \
--grpc-gateway_opt=paths=import \
--validate_out lang=go:pkg/ocp-check-api \
--swagger_out=allow_merge=true,merge_file_name=api:swagger \
api/ocp-check-api/ocp-check-api.proto
mv pkg/ocp-check-api/github.com/ozoncp/ocp-check-api/pkg/ocp-check-api/* pkg/ocp-check-api/
rm -rf pkg/ocp-check-api/github.com
mkdir -p cmd/ocp-check-api
mkdir -p pkg/ocp-test-api
protoc -I vendor.protogen \
--go_out=pkg/ocp-test-api --go_opt=paths=import \
--go-grpc_out=pkg/ocp-test-api --go-grpc_opt=paths=import \
--grpc-gateway_out=pkg/ocp-test-api \
--grpc-gateway_opt=logtostderr=true \
--grpc-gateway_opt=paths=import \
--validate_out lang=go:pkg/ocp-test-api \
--swagger_out=allow_merge=true,merge_file_name=api:swagger \
api/ocp-test-api/ocp-test-api.proto
mv pkg/ocp-test-api/github.com/ozoncp/ocp-check-api/pkg/ocp-test-api/* pkg/ocp-test-api/
rm -rf pkg/ocp-test-api/github.com
PHONY: .build
.build:
GIT_COMMIT=$(git rev-list -1 HEAD) CGO_ENABLED=0 GOOS=linux go build -ldflags \
"-X main.GitCommit=$(GIT_COMMIT) -X main.BuildDateTime=`date -u +%d.%m.%Y_%H:%M:%S`" -o bin/ocp-check-api cmd/ocp-check-api/main.go
PHONY: install
install: build .install
PHONY: .install
install:
go install cmd/grpc-server/main.go
PHONY: vendor-proto
vendor-proto: .vendor-proto
PHONY: .vendor-proto
.vendor-proto:
mkdir -p vendor.protogen
mkdir -p vendor.protogen/api/ocp-check-api
cp api/ocp-check-api/ocp-check-api.proto vendor.protogen/api/ocp-check-api
@if [ ! -d vendor.protogen/google ]; then \
git clone https://github.com/googleapis/googleapis vendor.protogen/googleapis &&\
mkdir -p vendor.protogen/google/ &&\
mv vendor.protogen/googleapis/google/api vendor.protogen/google &&\
rm -rf vendor.protogen/googleapis ;\
fi
@if [ ! -d vendor.protogen/github.com/envoyproxy ]; then \
mkdir -p vendor.protogen/github.com/envoyproxy &&\
git clone https://github.com/envoyproxy/protoc-gen-validate vendor.protogen/github.com/envoyproxy/protoc-gen-validate ;\
fi
mkdir -p vendor.protogen/api/ocp-test-api
cp api/ocp-test-api/ocp-test-api.proto vendor.protogen/api/ocp-test-api
@if [ ! -d vendor.protogen/google ]; then \
git clone https://github.com/googleapis/googleapis vendor.protogen/googleapis &&\
mkdir -p vendor.protogen/google/ &&\
mv vendor.protogen/googleapis/google/api vendor.protogen/google &&\
rm -rf vendor.protogen/googleapis ;\
fi
@if [ ! -d vendor.protogen/github.com/envoyproxy ]; then \
mkdir -p vendor.protogen/github.com/envoyproxy &&\
git clone https://github.com/envoyproxy/protoc-gen-validate vendor.protogen/github.com/envoyproxy/protoc-gen-validate ;\
fi
.PHONY: deps
deps: install-go-deps
.PHONY: install-go-deps
install-go-deps: .install-go-deps
.PHONY: .install-go-deps
.install-go-deps:
ls go.mod || go mod init
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
go install github.com/envoyproxy/protoc-gen-validate
.PHONY: install-migrate
install-migrate: .install-migrate
.PHONY: .install-migrate
.install-migrate:
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.14.1/migrate.linux-amd64.tar.gz | tar xvz && mv ./migrate.linux-amd64 ./migrate