Skip to content

Add support for policies in buf.lock #3780

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

emcfarlane
Copy link
Contributor

@emcfarlane emcfarlane commented Apr 21, 2025

This PR adds support for policies in the buf.lock file. The lock file includes a new field policies which declares a set of policies and their plugin keys. This is a hierarchical structure. A policy's remote plugins are versioned independently from other policies and the current lint/breaking plugin configuration. A local policy, defined by a path to a policy yaml file, may include remote plugins. This policy is stored as the name, without a commit or digest. A remote poilcy, defined by the BSR name, must have a name and digest.

As an example buf.lock supports the following:

version: v2
policies:
  # A locally defined policy file with remote plugins
  - name: buf.policy.yaml
    plugins:
      - name: buf.build/acme/plugin
        commit: ffded0b4cf6b47cab74da08d291a3c2f
        digest: p1:24ed4f13925cf89ea0ae0127fa28540704c7ae14750af027270221b737a1ce658f8014ca2555f6f7fcd95ea84e071d33f37f86cc36d07fe0d0963329a5ec2462
  # A remote policy with plugins.
  - name: buf.build/acme/policy
    commit: ffded0b4cf6b47cab74da08d291a3c2f
    digest: o1:24ed4f13925cf89ea0ae0127fa28540704c7ae14750af027270221b737a1ce658f8014ca2555f6f7fcd95ea84e071d33f37f86cc36d07fe0d0963329a5ec2462
    plugins:
      - name: buf.build/acme/plugin
        commit: ffded0b4cf6b47cab74da08d291a3c2f
        digest: p1:24ed4f13925cf89ea0ae0127fa28540704c7ae14750af027270221b737a1ce658f8014ca2555f6f7fcd95ea84e071d33f37f86cc36d07fe0d0963329a5ec2462

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

github-actions bot commented Apr 21, 2025

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 28, 2025, 6:14 PM

Base automatically changed from ed/bufPolicyYaml to main April 28, 2025 14:54
@emcfarlane emcfarlane marked this pull request as ready for review April 28, 2025 17:01
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.

1 participant