Skip to content

Conversation

@RoniKishner
Copy link
Contributor

@RoniKishner RoniKishner commented Jan 21, 2026

Short description:

Add validatingAdmissionPolicy and validatingAdmissionPolicyBinding

More details:
  • Add to ocp_resources validatingAdmissionPolicy class
  • Add to ocp_resources validatingAdmissionPolicyBinding class
  • Update _definitions.json file
What this PR does / why we need it:

Adding the resources for future use of the class

Summary by CodeRabbit

  • New Features

    • Added support for Kubernetes ValidatingAdmissionPolicy resource.
    • Added support for Kubernetes ValidatingAdmissionPolicyBinding resource.
  • Tests

    • Added lifecycle tests (create/retrieve/update/delete) for ValidatingAdmissionPolicy.
    • Added lifecycle tests (create/retrieve/update/delete) for ValidatingAdmissionPolicyBinding.
  • Documentation

    • Improved and clarified docstrings across generated manifest classes (Deployment, Ingress, Pod) and related tests.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Walkthrough

Adds two new Kubernetes resource wrapper classes—ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding—with parameterized initializers and to_dict implementations, plus tests for both; also includes multiple docstring/content refinements in generated manifest test files.

Changes

Cohort / File(s) Summary
Resource Classes
ocp_resources/validating_admission_policy.py, ocp_resources/validating_admission_policy_binding.py
Two new Resource subclasses added. ValidatingAdmissionPolicy accepts audit_annotations, failure_policy, match_conditions, match_constraints, param_kind, validations, variables. ValidatingAdmissionPolicyBinding accepts match_resources, param_ref, policy_name, validation_actions. Both implement to_dict to conditionally populate spec.
Test Suites
tests/test_resources/test_validating_admission_policy.py, tests/test_resources/test_validating_admission_policy_binding.py
New pytest modules covering lifecycle operations (create, get, update, delete) for the two new resources using fixtures and incremental tests.
Generated manifest docs / tests
class_generator/tests/manifests/..., class_generator/tests/test_class_generator.py
Documentation and docstring refinements across several manifest test files (Deployment, Ingress, Pod) and minor ordering/formatting changes in test_class_generator.py. No signature or behavioral changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Suggested labels

commented-coderabbitai[bot]

Suggested reviewers

  • myakove
  • rnetser
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: adding two new resource classes (validatingAdmissionPolicy and validatingAdmissionPolicyBinding) to the codebase, which aligns with the raw summary and file changes.
Description check ✅ Passed The description covers all required template sections with appropriate content. It provides short description, details about the added classes, clear rationale for the changes, and follows the repository template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@redhat-qe-bot
Copy link
Contributor

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest python-module-install - Test Python package installation
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 0 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No WIP, hold, conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@tests/test_resources/test_validating_admission_policy_binding.py`:
- Around line 16-21: The test is asserting the bound method object instead of
calling it; change the assertion to invoke the exists method (use
validatingadmissionpolicybinding.exists()) so the test checks the actual
resource state; locate the assertion in
test_01_create_validatingadmissionpolicybinding and replace the property-style
reference validatingadmissionpolicybinding.exists with a call to the exists()
method.
- Around line 35-39: In test_04_delete_validatingadmissionpolicybinding, the
test negates the method object instead of calling it—change the assertion to
call the exists() method on validatingadmissionpolicybinding (i.e., use
validatingadmissionpolicybinding.exists()) so the runtime boolean result is
checked; update the assertion to assert not
validatingadmissionpolicybinding.exists() and ensure any other references to
validatingadmissionpolicybinding.exists are similarly invoked as a method.

In `@tests/test_resources/test_validating_admission_policy.py`:
- Around line 50-54: The test_04_delete_validatingadmissionpolicy uses the
property-like reference validatingadmissionpolicy.exists instead of calling the
method, so the assertion always evaluates incorrectly; update the assertion to
call the method as validatingadmissionpolicy.exists() after
validatingadmissionpolicy.clean_up(wait=False) to properly verify the resource
no longer exists (ensure you reference the exists() method on the
validatingadmissionpolicy object).
- Around line 31-36: The test test_01_create_validatingadmissionpolicy uses
validatingadmissionpolicy.exists as a property but exists is a method; update
the assertion to call the method (validatingadmissionpolicy.exists()) so it
evaluates to a boolean, e.g., replace "assert validatingadmissionpolicy.exists"
with "assert validatingadmissionpolicy.exists()".

@RoniKishner RoniKishner force-pushed the validating-admission-policy branch from 24ddf00 to a840ac4 Compare January 21, 2026 12:59
@RoniKishner RoniKishner changed the title Add validatingAdmissionPolicy and validatingAdmissionPolicyBinding feat: Add validatingAdmissionPolicy and validatingAdmissionPolicyBinding Jan 21, 2026
@RoniKishner RoniKishner force-pushed the validating-admission-policy branch from a840ac4 to 0f1674d Compare January 21, 2026 13:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@class_generator/tests/test_class_generator.py`:
- Line 157: Replace the brittle "assert False, failure_summary" with a pytest
API call: call pytest.fail(...) using the existing failure_summary so the test
reliably fails even under Python -O; locate the assertion in
test_class_generator (the line with "assert False" referencing failure_summary)
and replace it with pytest.fail(failure_summary).
🧹 Nitpick comments (3)
class_generator/tests/test_class_generator.py (3)

63-71: Explicit strict=False would clarify intent.

The removal of strict=True is intentional since different-length files are handled separately (lines 70-71). Consider adding explicit strict=False to document this intent and silence the linter.

💡 Suggested clarification
-                    for i, (gen_line, exp_line) in enumerate(zip(generated_lines, expected_lines)):
+                    for i, (gen_line, exp_line) in enumerate(zip(generated_lines, expected_lines, strict=False)):

116-118: Unused kind parameter is required by interface.

The kind parameter is unused but required by the execute_parallel_tasks result_processor signature (Callable[[T, R], Any]). Consider adding _ prefix to indicate intentionally unused: _kind.

💡 Suggested clarification
-    def process_test_result(kind: str, result: Optional[Tuple[str, str]]) -> None:
+    def process_test_result(_kind: str, result: Optional[Tuple[str, str]]) -> None:

120-122: Consider f-string conversion flag (nitpick).

Static analysis suggests using {exc!s} instead of {str(exc)} for f-string idiomatic style. Both work identically.

💡 Suggested change
     def handle_test_error(kind: str, exc: Exception) -> None:
-        failures.append((kind, f"Task execution failed: {str(exc)}"))
+        failures.append((kind, f"Task execution failed: {exc!s}"))

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
class_generator/tests/test_class_generator.py (1)

94-111: Add ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding to the test resource list.

These auto-generated resources are missing from the resource_kinds list for the test_parse_explain test. Test manifest files should also be created in class_generator/tests/manifests/ValidatingAdmissionPolicy/ and class_generator/tests/manifests/ValidatingAdmissionPolicyBinding/ to enable test coverage for these resources.

♻️ Duplicate comments (1)
class_generator/tests/test_class_generator.py (1)

152-157: Good improvement; pytest.fail() remains an option.

The change from assert False to raise AssertionError correctly addresses the -O optimization concern (B011). The previous review suggested pytest.fail() which is already imported and is the idiomatic pytest approach for explicit test failures. Either approach works; pytest.fail() provides slightly better integration with pytest's failure reporting.

🧹 Nitpick comments (2)
class_generator/tests/test_class_generator.py (2)

63-68: Consider adding strict=False to clarify intent.

Static analysis flags zip() without strict= (B905). The current behavior is correct—you want to compare as many lines as possible and handle length differences separately at lines 70-71. Adding explicit strict=False would silence the linter and document the intent.

♻️ Proposed fix
-                    for i, (gen_line, exp_line) in enumerate(zip(generated_lines, expected_lines)):
+                    for i, (gen_line, exp_line) in enumerate(zip(generated_lines, expected_lines, strict=False)):

116-118: Consider using _kind to indicate intentionally unused parameter.

The kind parameter is required by the execute_parallel_tasks API but unused here. Using an underscore prefix silences the linter and documents the intent.

♻️ Proposed fix
-    def process_test_result(kind: str, result: Optional[Tuple[str, str]]) -> None:
+    def process_test_result(_kind: str, result: Optional[Tuple[str, str]]) -> None:

@RoniKishner
Copy link
Contributor Author

/verified
run on https://github.com/RoniKishner/openshift-virtualization-tests/commit/56576a78dbfab3c4b2af5e781685435e85961a4b

@myakove
Copy link
Collaborator

myakove commented Jan 22, 2026

/hold

@myakove
Copy link
Collaborator

myakove commented Jan 22, 2026

/hold cancel

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.

6 participants