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

Plugin request for Buf Schema Registry: protopatch #858

Closed
samborkent opened this issue Oct 11, 2023 · 3 comments · Fixed by alta/protopatch#174
Closed

Plugin request for Buf Schema Registry: protopatch #858

samborkent opened this issue Oct 11, 2023 · 3 comments · Fixed by alta/protopatch#174
Labels
Feature New feature or request

Comments

@samborkent
Copy link

samborkent commented Oct 11, 2023

This plugin allows to wrap calls of code generators and patch them before writing. This allows users to circumvent most syntax issues that come with using protobuf and Go code generation. For example, item_id is parsed to ItemId instead ItemID as per Go's style guide.

Another glaring issue is enum types which generate horrendous Go types as follows:

enum EnumExample {
    ENUM_EXAMPLE_UNSPECIFIED = 0;
    ...
}

Which is compiled as EnumExample_ENUM_EXAMPLE_UNSPECIFIED.

Both of these issues and other ugly syntax issues can be solved with this plugin. The plugin is actively maintained and would be a great addition to the buf ecosystem.

Mandatory

Where is the source code for the plugin?

https://github.com/alta/protopatch

Optional

Does the plugin have a valid semver version?

v0.5.3

@samborkent samborkent added the Feature New feature or request label Oct 11, 2023
@mfridman
Copy link
Member

Thanks for filing an issue. I'm afraid this plugin won't work as a Remote Plugin because it shells out other protoc-gen-* plugins.

It's a neat plugin, but it's best run locally.

ps. For the enum issue, that should be solved in the generator itself (at least with an opt-in option to maintain compatibility). There's an issue to track this golang/protobuf#513

@Jonathan-Landeed
Copy link

Jonathan-Landeed commented Oct 5, 2024

It would still be nice to have a BSR repo. Usage requires import "patch/go.proto";, which has to be made available with buf.yaml->modules->path or buf.yaml->deps. A github repo or installed go package can't be used for either.

I was able to get it working by replacing

  - local: protoc-gen-go
    out: gen
    opt: paths=source_relative

with

  - local: protoc-gen-go-patch
    out: gen
    opt:
      - paths=source_relative
      - plugin=go

and adding /proto/patch/go.proto to my project. Looks like someone else made their own BSR repo for this: https://buf.build/nvxx/protopatch/tree/main

Edit:
I've added https://github.com/Landeed/protopatch and https://buf.build/landeed/protopatch so this works:

deps:
  - buf.build/landeed/protopatch

Just don't forget to buf dep update.

@ydnar
Copy link

ydnar commented Oct 5, 2024

Hi, author of protopatch. I'm happy to help with necessary integrations if folks want to use it with Buf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants