Skip to content

policy: preallocate builtin capabilities - #4181

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

thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:policy_followup

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

Pass custom policy functions to builtins() so that the complete builtin list can be constructed with a single allocation.

This avoids growing the builtin slice when adding custom functions.

Updates 8b1d06a

Pass custom policy functions to builtins() so that the complete
builtin list can be constructed with a single allocation.

This avoids growing the builtin slice when adding custom functions.

Updates 8b1d06a

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.

🟢 Approval recommended

No active review issues are reported for the capability-construction optimization.

No open issues 🎉

What changed in this PR

Optimizes policy capability construction following the migration to OPA’s WithCapabilities, preallocating space for both default and custom builtins to avoid slice growth.

Changes:

  • Passes custom policy functions directly to builtins.
  • Allocates the combined builtin slice with sufficient capacity before appending entries.
File Description
policy/​validate.go Delegates custom builtin inclusion to builtins(p.funcs).
policy/​builtins.go Preallocates capacity for default and custom builtins and assembles the combined list.

Review effort: Balanced

This branch has not been deployed

No deployments
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