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.
Explanation
This PR addresses the issue #12456, #10406 by fixing the resource filtering logic inside the test-case-selector flag. According to the 8000 documention, the test-case-selector allows to run a subset of tests based on policy, rule and resource. However, current behavior of the Kyverno's test-case-selector allows filtering the test cases by policy and rule, but fails to apply filtering based on the resource name. As a result, even when a specific resource is provided via the selector, all the resources are tested instead of the mentioned one. This fix ensures that test cases are filtered by resource selector as well.
Related issue
Closes #12456, #10406
Milestone of this PR
What type of PR is this
/kind bug
Proposed Changes
This PR addresses a bug in the test-case-selector functionality of the Kyverno CLI, where the resource filter was previously ineffective. Despite specifying a resource using the --test-case-selector flag (e.g., resource=nginx-demo2), the CLI continued to run tests against all resources instead of filtering by the specified one. This behavior was inconsistent with the intended functionality described in the official documentation. The proposed fix ensures that the resource value is now properly parsed and respected during test selection, enabling users to run targeted tests based on policy, rule, and resource
Before:
After:
Proof Manifests
require-pod-requests-limits.yaml
resource.yaml
kyverno-test.yaml
Proof Manifests
Checklist
Further Comments