Skip to content

Commit

Permalink
feat: add buf generate
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilSharma03 committed Dec 25, 2023
1 parent ca45599 commit e3ae1ac
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 18 deletions.
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# gen-protobuf generates .pb.go for protobuf files
gen-protobuf:
.PHONY: generate-proto-protoc
generate-proto-protoc:
protoc -I ./api \
--go_out ./pkg --go_opt paths=source_relative \
--go-grpc_out ./pkg --go-grpc_opt paths=source_relative \
--grpc-gateway_out ./pkg --grpc-gateway_opt paths=source_relative \
./api/protobuf/*.proto ./api/google/api/*.proto ./api/google/type/*.proto
--go-grpc_out ./pkg --go-grpc_opt paths=source_relative \
--grpc-gateway_out ./pkg --grpc-gateway_opt paths=source_relative \
./api/protobuf/*.proto ./api/google/api/*.proto ./api/google/type/*.proto

.PHONY: generate-proto
generate-proto:
buf generate api

# clean-protobuf removes generated .pb.go files
clean-protobuf:
.PHONY: clean-proto
clean-proto:
rm -rf pkg/protobuf pkg/google

# run-server starts the grpc server
.PHONY: run-server
run-server:
go run cmd/main.go

# build-cli builds the cli app
build-cli:
cd cli; go build -o okane; mv okane ./../okane-cli
7 changes: 7 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
2 changes: 1 addition & 1 deletion api/google/api/annotations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
}
15 changes: 15 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: v1
plugins:
- plugin: go
out: pkg
opt:
- paths=source_relative
- plugin: go-grpc
out: pkg
opt:
- paths=source_relative
- plugin: grpc-gateway
out: pkg
opt:
- paths=source_relative
- generate_unbound_methods=true
4 changes: 4 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v1
directories:
- api

2 changes: 1 addition & 1 deletion pkg/google/api/annotations.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/google/api/http.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/google/type/money.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/protobuf/okane.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/protobuf/okane_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3ae1ac

Please sign in to comment.