-
Notifications
You must be signed in to change notification settings - Fork 284
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
Use Workspaces for buf config ls rules #3537
Conversation
This refactors the commands buf config {ls-lint-rules, ls-breaking-rules} to utilize workspaces. Workspaces allow for re-use of validation and provide more information about the source.
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
@@ -92,6 +92,7 @@ type Workspace interface { | |||
// handle v1 vs v2 transparently. Right now, this is only approved to be used in push | |||
// when we want to know whether we need to print out only CommitIDs. Any other usages | |||
// need to be evaluated. | |||
// TODO: Validate the usecase for `buf config ls-lint-rules` and `buf config ls-breaking-rules`. | |||
IsV2() bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change uses the IsV2
method to restrict use of the flag --module-path
to only work on v2 Workspaces and read the version for use with bufcheck.Client
AllRules
method. The current behaviour reads the version directly from the buf.yaml
file.
bufcheck.WithPluginConfigs(workspace.PluginConfigs()...), | ||
} | ||
fileVersion := bufconfig.FileVersionV1 | ||
if workspace.IsV2() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to modify Workspace to return the version as bufconfig.FileVersion
here, as there is currently no way to tell if the version is v1, v1beta1 or v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that doesn't make sense at a Workspace
level though, since v1
and v1beta1
buf.yaml
versions are module-level concerns... we may need to rethink this refactor a little bit.
This refactors the commands
buf config {ls-lint-rules, ls-breaking-rules}
to utilize Workspaces. Workspaces allow for re-use of the validation for config overrides and provide more information about the source.