Hey all! Is there a way to pass a buf config file ...
# general
a
Hey all! Is there a way to pass a buf config file to buf linter (backend → pants.backend.codegen.protobuf.lint.buf) ? I’ve been trying to set:
Copy code
[buf]
lint_args = [
  "--config buf.yaml"
]
and tried several paths, raw or with targets, without any success. It feels unlikely to work as protos are likely to be declared with
protobuf_sources
that does not accept any other file types than
.proto
. A workaround would be to pass the yaml (or json) content of the config file directly in the config option, but it’s not really maintainable as the config grows. Any idea?
f
Are you getting a specific error?
a
Yes, always
Failure: could not read file: open buf.yaml: no such file or directory
From what I understand, the linter expects to find the file in the sandbox, along with the proto files?
f
Yes. The buf rules would need to be updated to understand how to find an applicable config file and include it in the sandbox.
The pytest and scalafmt rules have examples of this.
Maybe open an issue? And include what the expected UX could be. Would it be a repo-wide config file? Or a config file for a subtree (like the scalafmt config)?
I.e., what are your expectations for the UX as a buf user.
Also useful to know is what is the UX for buf when it is used standalone.
a
I feel like we could have a generic
config
option within
[buf]
in pants.toml (rather than lint_args and format_args) as the config in the yaml already expects a “lint” and “format” section. My current need is repo-wide indeed, but no strong opinion to be fair, I just don’t have any example where project-only config would be better. I have also tried to declare the config file into a
resource
target, and add it to the dependencies of my
protobuf_source
. I would expect it to be a strong information for pants’
lint
goal to be able to discover the config file automatically, but not quite sure it’s supposed to behave like this. I’ll open an issue then!