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

Monorepository package based buf generator #2440

Closed
christiankaseburg opened this issue Sep 13, 2023 · 1 comment
Closed

Monorepository package based buf generator #2440

christiankaseburg opened this issue Sep 13, 2023 · 1 comment
Labels
Feature New feature or request

Comments

@christiankaseburg
Copy link

christiankaseburg commented Sep 13, 2023

Hey all,

I have a monorepository with multiple APIs. I am migrating from protoc to buf for generating my gRPC, gRPC-Gateway, and openapiv2 code from my .proto files for each API. Currently, I have a root buf.worker.yaml that contains my shared libraries in my libs/proto and a buf.gen.yaml file per API that uses the same plugins, but different output paths since I want the generated code to be output relative to the API the code is being generated for. I'm not sure if this is the right approach and am looking for feedback if there is a way to control the output path to be relative to the API the code is being generated for. If I am able to do that I can create a buf.gen.api.yaml file in my root and reuse that as my template for each API if I can specify the root output to be the API the code is being generated for.

For example, I have a mono repository structure like this:

/root
   /apps
      /api-a
         /cmd
         /internal
            /proto
            buf.yaml
            buf.gen.yaml
            service-a.proto
      /api-b
         /cmd
         /internal
            /proto
            buf.yaml
            buf.gen.yaml
            service-b.proto
      /api-c
         /cmd
         /internal
            /proto
            buf.yaml
            buf.gen.yaml
            service-c.proto
   /libs
      /proto
         /google
            /api
               annotations.proto
               http.proto
buf.worker.yaml

I would prefer to be able to remove the buf.gen.yaml per API and instead have a template in my root called "buf.gen.api.yaml" since the only part that is different is the output path. Then I would bbe able to use a command such as buf generate --template buf.gen.api.yaml --path apps/api-a/internal/proto --outputroot apps/api-a and then output the generated code relative to the outputroot path.

Does my current solution work or is there a way to create an approach similiar to the one above and remove the duplication buf.gen.yaml files per API since they use the same plugins and just need the output to be relative to the api the code is being generated for?

@doriable doriable added Feature New feature or request and removed Feature New feature or request labels Jun 10, 2024
@doriable doriable assigned doriable and unassigned doriable Jun 10, 2024
@doriable doriable added the Feature New feature or request label Jun 10, 2024
@doriable
Copy link
Member

This is a similar feature request to #3060, which is supporting plugin configurations on a per module/input basis, so closing as a duplicate of that issue to consolidate all discussion there.

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

No branches or pull requests

2 participants