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

Support inputs in buf.gen.yaml #1424

Closed
Aqours opened this issue Sep 21, 2022 · 5 comments
Closed

Support inputs in buf.gen.yaml #1424

Aqours opened this issue Sep 21, 2022 · 5 comments
Labels
Feature New feature or request

Comments

@Aqours
Copy link

Aqours commented Sep 21, 2022

Usage Scenario

Generate multiple BSR modules

buf generate buf.build/googleapis/example1
buf generate buf.build/googleapis/example2
buf generate buf.build/googleapis/example3

Expected

  1. Support multiple input modules
buf generate buf.build/googleapis/example1 \
             buf.build/googleapis/example2 \
             buf.build/googleapis/example3
  1. Support config in buf.gen.yaml
version: v1
plugins:
  - name: xxx
modules:
  - buf.build/googleapis/example1
    buf.build/googleapis/example2
    buf.build/googleapis/example3
buf generate
@robbertvanginkel
Copy link
Contributor

Regarding point 2, buf.gen.yaml's intention is to be input agnostic and the current stance is that we will not support inputs in the generate config file (see also #510). Similarly various parts of buf are designed to operate on one module at a time and there are no plans to support multi module inputs. If you have a need to have only one buf invocation, would xargs -n1 suit your needs?

Based on #1407 (comment) we may revisit the input agnostic idea of buf.gen.yaml in the future. This ticket is linked now and we'll take the feedback into account for those discussions.

@robbertvanginkel robbertvanginkel added the Feature New feature or request label Sep 21, 2022
@bufdev bufdev changed the title Can buf generate mod support multiple input? Support inputs in buf.gen.yaml Jan 14, 2023
@bufdev
Copy link
Member

bufdev commented Jan 14, 2023

This isn't going to happen in the near-term, but is something we're reconsidering. Generally, we may want buf.gen.yaml files to be input-aware. Going to keep open for now.

@bufdev
Copy link
Member

bufdev commented Jan 14, 2023

When looking at this issue in the future, we should also look at #1407 - going to close that issue and track this only here.

@timostamm
Copy link
Member

Another use case (similar to #1407) would be to allow type filtering and (a new feature) option redaction at the plugin level. The latter would be useful to omit certain options from generated code in order to not ship them in a frontend bundle (bufbuild/protobuf-es#397).

@oliversun9
Copy link
Contributor

buf.gen.yaml v2 supports multiple inputs now. Your file may look like:

version: v2
plugins:
# ...
inputs:
  - module: buf.build/googleapis/example1
  - module: buf.build/googleapis/example2
  - module: buf.build/googleapis/example3

Before adding an inputs section, you can have the rest of your buf.gen.yaml ready by running the migration command:

buf config migrate

or

buf config migrate --buf-gen-yaml path/to/buf.gen.yaml

if your buf.gen.yaml is not at the current directory or named differently. Use the --diff flag to only display the difference between your upgraded and current file.

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

5 participants