Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: introduce buf for code generation #2515

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Before sending pull request, please make sure that your changes have passed both

## Changing the gRPC API

### Origin go-tools approach

If you change the gRPC API, generate `api/*.pb.go` in the following way:

```bash
Expand All @@ -25,6 +27,14 @@ $ ./tools/grpc/genproto.sh

In order for the script to run, you'll need protoc (version 3.19.1) in your PATH.

### Using `buf`

[buf](https://github.com/bufbuild/buf) is a morden tool for managing `Protobuf`. Installation guide can be found [here](https://docs.buf.build/installation).

To generate the `go` code from proto definitions, once the `buf` is installed on local system, just run `buf generate api` on the root level of `gobgpd` project. It will produce `api/*.pb.go` in `github.com/osrg/gobgp/api` folder as it is when using `go-tools` appraoch.

This new tool has the potential in future to help increase compatilibity and stability through out API changes and refactoring.

## Releases

GoBGP releases are time-based. Minor releases will occur every month ([Semantic Versioning](https://semver.org/)). Major releases occur only when absolutely necessary.
Expand Down
11 changes: 11 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
ignore:
- attribute.proto
- capability.proto
- gobgp.proto
10 changes: 10 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1
plugins:
- name: go
out: api
opt: paths=source_relative
- name: go-grpc
out: api
opt:
- paths=source_relative
- require_unimplemented_servers=true