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

Add support for name filtering in buf generate command #854

Closed
remyleone opened this issue Jan 14, 2022 · 9 comments
Closed

Add support for name filtering in buf generate command #854

remyleone opened this issue Jan 14, 2022 · 9 comments
Labels
Feature New feature or request Wishlist Things we'd want in the future

Comments

@remyleone
Copy link

If I have multiple generators defined in my buf.gen.yaml, sometimes I want only to launch a subset of the generators. Could it be possible for the buf generate command to accept a name option/filter that will only select a subset of the generators defined in the config file or pass through the template option?

@robbertvanginkel
Copy link
Contributor

We currently treat buf.gen.yaml as all or nothing in terms of running all defined codegenerators, similar to how templates are defined and work with remote generation on the BSR.

If you want to be able to run different sets of generators, we currently recommend that you keep multiple buf.subset.gen.yaml files and use the --template flag when doing buf generate. Note that the --template doesn't only take files but can also take a json encoded template from the commandline. Is that a solution that would work for you?

@remyleone
Copy link
Author

That would mean duplicating configuration for all generators in all the subsets files :/ the number of files to keep on disk will keep growing with this solution. Filtering seems to be more elegant.

@amckinney
Copy link
Contributor

I want to challenge this a bit. I'm not sure that you'd need to duplicate anything across any files - you just need to write your files granularly so that they can composed together by separate buf generate invocations. I think the number of files you'd need is equivalent to the number of buf generate --name invocations you'd need to write if we supported a --name filter, right?

Regardless, a --name filter is a reasonable request - we can consider it, but we have taken a strict stance that input configuration goes in flags, template configuration goes in buf.gen.yaml, and this would make that split murkier.

I also worry about the implication on other features in the buf.gen.yaml like Managed Mode. If we have a way to select individual plugins, would we also need a way to enable/disable different parts of the managed key? This could quickly get unwieldy if so.

@anandwana001
Copy link

anandwana001 commented Jan 20, 2022

We currently treat buf.gen.yaml as all or nothing in terms of running all defined codegenerators, similar to how templates are defined and work with remote generation on the BSR.

If you want to be able to run different sets of generators, we currently recommend that you keep multiple buf.subset.gen.yaml files and use the --template flag when doing buf generate. Note that the --template doesn't only take files but can also take a json encoded template from the commandline. Is that a solution that would work for you?

@robbertvanginkel How to keep multiple buf.subset.gen.yaml files? It rises the duplicate name issue in project.

If we prefer a subset like this in generating command only, then how does it affect buf.gen.yaml file? Does it override or not?
https://docs.buf.build/generate/usage#common-use-cases

@bufdev
Copy link
Member

bufdev commented Jan 20, 2022

Here's how we maintain multiple sets: https://github.com/bufbuild/buf/tree/main/data/template

You can use the --template flag https://github.com/bufbuild/buf/blob/main/make/buf/all.mk#L104

@bufdev
Copy link
Member

bufdev commented Feb 3, 2022

I think for now we're going to close this: the canonical way to do this currently is with having multiple buf.gen.yaml files, and we don't want to mix responsibilities between flags and config files as described above. We can revisit in the future if there's a big need for this.

@bufdev bufdev closed this as completed Feb 3, 2022
@bufdev bufdev reopened this Feb 17, 2022
@bufdev
Copy link
Member

bufdev commented Feb 17, 2022

We're going to reconsider this

@amckinney amckinney added Feature New feature or request Wishlist Things we'd want in the future labels Aug 10, 2022
@AndreasBergmeier6176
Copy link

Our use case would be to filter the files that get considered in a plugin entry.
E.g. when we have foo.proto and bar.proto it would be great to be able to directly specify, which protos will be used for the plugin invocation.

Basically a mechanism which loads the path option from buf.gen.yaml.

@doriable
Copy link
Member

Closing this issue as a duplicate of #3060 to consolidate discussion on supporting plugin configurations on a per module/input basis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request Wishlist Things we'd want in the future
Projects
None yet
Development

No branches or pull requests

7 participants