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

Use Workspaces for buf config ls rules #3537

Closed
wants to merge 1 commit into from

Conversation

emcfarlane
Copy link
Contributor

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.

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.
Copy link
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedDec 12, 2024, 7:24 PM

@@ -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
Copy link
Contributor Author

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() {
Copy link
Contributor Author

@emcfarlane emcfarlane Dec 12, 2024

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.

Copy link
Member

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.

@emcfarlane emcfarlane closed this Dec 12, 2024
@emcfarlane emcfarlane deleted the ed/lsRulesUseWorkspace branch December 13, 2024 10:53
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

Successfully merging this pull request may close these issues.

2 participants