Skip to content

evaluator: update implementation and tests; refresh policy test fixtures#1

Closed
zemanlx wants to merge 4 commits into
mainfrom
feat/namespace-selector-support
Closed

evaluator: update implementation and tests; refresh policy test fixtures#1
zemanlx wants to merge 4 commits into
mainfrom
feat/namespace-selector-support

Conversation

@zemanlx

@zemanlx zemanlx commented Feb 13, 2026

Copy link
Copy Markdown
Owner
  • Update internal/evaluator implementation and improve unit tests.
  • Modify main.go to align with evaluator changes.
  • Add/refresh multiple policy bindings and test cases under test-policies-pass (mutating and validating suites).
  • Update golden testdata files in testdata/.

Copilot AI left a comment

Copy link
Copy Markdown

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 adds support for namespace selector matching in Kubernetes admission policy bindings. The evaluator now properly evaluates namespaceSelector specifications in both ValidatingAdmissionPolicyBinding and MutatingAdmissionPolicyBinding objects, allowing policies to be selectively applied based on namespace labels.

Changes:

  • Added namespace selector evaluation logic in the evaluator with two new helper functions
  • Updated EvaluateTest, evaluatePolicy, EvaluateMutating, and EvaluateValidating to accept and use binding parameters
  • Modified main.go to look up and pass both policies and their bindings to the evaluator
  • Added comprehensive test fixtures for namespace selector scenarios (In, NotIn, Exists, DoesNotExist operators)

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/evaluator/evaluator.go Added matchesNamespaceSelector and matchesNamespaceSelectorV1Beta1 functions; updated evaluation functions to accept and evaluate bindings
internal/evaluator/evaluator_test.go Updated test structure to include mutatingBinding parameter in function calls
internal/evaluator/evaluator_params_test.go Updated EvaluateMutating call to pass nil for mutating binding parameter
internal/evaluator/evaluator_authorizer_test.go Updated EvaluateMutating call to pass nil for mutating binding parameter
main.go Updated findPolicies to return bindings and modified runSuite to pass bindings to evaluator
test-policies-pass/validating/namespace-selector-binding/* New test policy demonstrating In operator for namespace selector
test-policies-pass/validating/namespace-selector-doesnotexist/* New test policy demonstrating DoesNotExist operator
test-policies-pass/validating/namespace-selector-operators/* New test policy demonstrating NotIn and Exists operators
test-policies-pass/mutating/namespace-selector-binding-mutating/* New test policy demonstrating namespace selector in mutating policies
testdata/*.golden Updated golden files to include new test fixtures and their passing results

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/evaluator/evaluator.go Outdated
- Update `internal/evaluator` implementation and improve unit tests.
- Modify `main.go` to align with evaluator changes.
- Add/refresh multiple policy bindings and test cases under `test-policies-pass` (mutating and validating suites).
- Update golden testdata files in `testdata/`.
@zemanlx zemanlx force-pushed the feat/namespace-selector-support branch from eac17f9 to dc12d65 Compare February 19, 2026 14:26

Copilot AI commented Feb 19, 2026

Copy link
Copy Markdown

@zemanlx I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 19, 2026 14:30
Co-authored-by: zemanlx <18702153+zemanlx@users.noreply.github.com>
evaluator: deduplicate namespace selector matching via shared helper
@zemanlx zemanlx closed this Feb 19, 2026
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