Skip to content

Add buf policy YAML file config #3769

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

Merged
merged 4 commits into from
Apr 28, 2025
Merged

Add buf policy YAML file config #3769

merged 4 commits into from
Apr 28, 2025

Conversation

emcfarlane
Copy link
Contributor

@emcfarlane emcfarlane commented Apr 14, 2025

This adds support for buf policy configuration. A new field in buf.yaml files (policies) takes an array of PolicyConfig and a new external file type BufPolicyYAMLFile for defining a policy.

@emcfarlane emcfarlane requested a review from doriable April 14, 2025 14:39
Copy link
Contributor

github-actions bot commented Apr 14, 2025

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 26, 2025, 10:38 AM

@emcfarlane emcfarlane marked this pull request as ready for review April 21, 2025 14:28
testReadWriteBufPolicyYAMLFileRoundTrip(
t,
// input
`version: v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, this is the first policy file version, why we're starting at v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file will consume v2 lint/breaking config options, so we went with v2 to clarify its related to the v2 spec.

Copy link
Member

@doriable doriable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think buf_policy_yaml_file.go should live under bufpkg/bufconfig, because it is not a a configuration file for buf. It is much closer in nature to bufremotepluginconfig (https://github.com/bufbuild/buf/tree/main/private/bufpkg/bufremoteplugin/bufremotepluginconfig) where it is the configuration of an specific entity. In this case, it is also the content of said entity. So I would move the policy YAML under bufpolicy as a sub-package, bufpolicyconfig, and go from there (policy_config.go and the changes to buf.yaml would stay in bufconfig).

}
)

// BufPolicyYAMLFile represents a buf.policy.yaml file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of buf.policy.yaml, could we say something like:

BufPolicyYAMLFile represents a policy configuration YAML file.

Just because this is meant to be generic.

@emcfarlane emcfarlane merged commit 07b899e into main Apr 28, 2025
10 checks passed
@emcfarlane emcfarlane deleted the ed/bufPolicyYaml branch April 28, 2025 14:54
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.

3 participants