policy: remove uses of deprecated WithBuiltins#3914
Open
thaJeztah wants to merge 1 commit into
Open
Conversation
thaJeztah
commented
Jun 16, 2026
| } | ||
|
|
||
| func compilePolicyModules(modules map[string]*ast.Module, p *Policy, fsProvider func() (fs.StatFS, func() error, error)) (*ast.Compiler, func() error, error) { | ||
| func policyCapabilities(funcs []fun) *ast.Capabilities { |
Member
Author
There was a problem hiding this comment.
May as well make this a non-exported methods on Policy; let me update
Member
Author
The WithBuiltins method was deprecated in opa v0.23.0 ([opa@afc8c5e]) in favor of WithCapabilities, but the deprecation didn't use the standard format, causing it not being detected as deprecated. OPA v1.1.0 corrected the deprecation in [opa@622434d]. This patch replaces uses of the deprecated functions. [opa@afc8c5e]: open-policy-agent/opa@afc8c5e [opa@622434d]: open-policy-agent/opa@622434d Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
219b40a to
8b1d06a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the policy compilation setup to avoid using OPA’s deprecated WithBuiltins compiler API, aligning the code with the newer WithCapabilities approach introduced/fixed in newer OPA releases.
Changes:
- Introduce a shared
(*Policy).capabilities()helper that builds anast.Capabilitiesincluding both standard and policy-specific builtins. - Update policy compilation paths to use
WithCapabilities(p.capabilities())instead ofWithBuiltins(...). - Remove now-unneeded
slicesimport frompolicy/tester.go.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| policy/validate.go | Adds capabilities() and switches compiler setup to rely solely on WithCapabilities, removing deprecated WithBuiltins usage. |
| policy/tester.go | Simplifies module compilation by reusing p.capabilities() and drops the old WithBuiltins path (and the unused slices import). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The WithBuiltins method was deprecated in opa v0.23.0 (opa@afc8c5e) in favor of WithCapabilities, but the deprecation didn't use the standard format, causing it not being detected as deprecated. OPA v1.1.0 corrected the deprecation in opa@622434d.
This patch replaces uses of the deprecated functions.