Skip to content

policy: remove uses of deprecated WithBuiltins#3914

Open
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:policy_no_deprecated
Open

policy: remove uses of deprecated WithBuiltins#3914
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:policy_no_deprecated

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

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.

Comment thread policy/tester.go Outdated
}

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 {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

May as well make this a non-exported methods on Policy; let me update

@thaJeztah

Copy link
Copy Markdown
Member Author

GitHub having issues again?

Screenshot 2026-06-16 at 15 09 41

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 an ast.Capabilities including both standard and policy-specific builtins.
  • Update policy compilation paths to use WithCapabilities(p.capabilities()) instead of WithBuiltins(...).
  • Remove now-unneeded slices import from policy/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.

@thaJeztah thaJeztah requested a review from tonistiigi June 16, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants