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

Modules with different buf.gen.yaml configs #2373

Open
pd93 opened this issue Aug 11, 2023 · 0 comments
Open

Modules with different buf.gen.yaml configs #2373

pd93 opened this issue Aug 11, 2023 · 0 comments

Comments

@pd93
Copy link

pd93 commented Aug 11, 2023

I'm trying to convert a monorepo project into a workspace and use modules for each of our services. However, some of our modules require different buf.gen.yaml configurations and I'm struggling to understand how I should go about doing this. Some examples of config differences:

  • Some legacy protos use the GRPC plugin and some newer things are using the Connect plugins. I don't want to generate GRPC code if I don't need it and vice versa.
  • Some of our modules only need to generate Go code, and some of them need to generate Go and Typescript. To make things worse, the Typescript generators require an npm package and I really don't want to put a package.json in our monorepo root just for Typescript generation.
  • I'd like to use the managed go_package_prefix setting, but this would be different per module.

I would expect to be able to create a buf.gen.yaml in each module and run buf generate from the project root, but unfortunately this gives me the error Failure: buf.gen.yaml: does not exist and if I create one, everything uses that global config instead of the module specific ones.

I see that I could use the --template and --path options and specify the service-specific buf.gen.yaml and the path to the service's proto that I want to generate code from, but this doesn't feel nice and removes one of the main advantages of using a workspace IMO.

Am I misunderstanding something about how to set this up or is this simply something that workspaces can't do at the moment?

Rough recreation of the project layout:

.
├── service1
│   ├── proto
│   │   └── ...
│   ├── buf.gen.yaml
│   └── buf.yaml
│   service2
│   ├── proto
│   │   └── ...
│   ├── buf.gen.yaml
│   └── buf.yaml
│   service3
│   ├── proto
│   │   └── ...
│   ├── buf.gen.yaml
│   └── buf.yaml
└── buf.work.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant