feat: add aap_job_template_id support to Hook class#2759
Conversation
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Cherry-pick Operations
Branch Management
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
Security Checks
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesHook compatibility shim migration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoAdd AAP/AWX job template support to MTV Hook resource
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Positional args API break
|
a19aa01 to
3f9a036
Compare
3f9a036 to
517e05f
Compare
|
/verified |
|
We're landing the schema-aligned generated Hook in a separate PR: #2765 (ocp_resources/_hook_generated.py Once #2765 (#2765) merges, please retarget this PR to:
Example shim shape: from ocp_resources._hook_generated import Hook as _GeneratedHook
_UNSET = object()
_DEFAULT_IMAGE = "quay.io/konveyor/hook-runner:latest"
class Hook(_GeneratedHook):
def __init__(self, aap=None, deadline=None, image=_UNSET, playbook=None, service_account=None, **kwargs):
warnings.warn(
"Hook legacy defaults are deprecated and will be removed. "
"Pass image= explicitly for local hooks; use aap={...} for AAP hooks.",
DeprecationWarning,
stacklevel=2,
)
if image is _UNSET:
image = None if aap is not None else _DEFAULT_IMAGE
super().__init__(
aap=aap,
deadline=deadline,
image=image,
playbook=playbook,
service_account=service_account,
**kwargs,
) MTV call site change: Hook(aap_job_template_id=9) → Hook(aap={"jobTemplateId": 9}). |
|
/hold |
|
AmenB is not part of the approver, only approvers can mark pull request with hold |
Head branch was pushed to by a user without write access
0510388 to
15bbb54
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ocp_resources/hook.py`:
- Around line 27-34: In the hook initialization logic, move the
DeprecationWarning into the `if image is _UNSET:` block so explicitly supplied
images do not trigger it. Add the requested TODO in that block documenting
removal of the legacy fallback, while preserving the existing `aap`-dependent
image assignment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4be5a318-eba3-46dc-b17b-f6f49c227353
📒 Files selected for processing (1)
ocp_resources/hook.py
Add support for AAP (Ansible Automation Platform) hooks. When aap_job_template_id is set, to_dict() produces spec.aap.jobTemplateId instead of spec.image + spec.playbook. The two hook types are mutually exclusive. Also adds type annotations to all __init__ parameters.
15bbb54 to
e346681
Compare
|
Clean rebase detected — no code changes compared to previous head ( |
Summary
Add
aap_job_template_idparameter to theHookclass, enabling MTV AAP hook integration — Hook CRs that trigger AWX/AAP job templates during migration instead of running playbooks in containers.What changed
aap_job_template_id=NoneonHook.__init__().to_dict():aap_job_template_idis set → producesspec.aap.jobTemplateId.spec.image+spec.playbook(existing behavior, unchanged).No regression — existing callers that don't pass
aap_job_template_idhit the original code path.Why
The
mtv-api-testsproject (branchfeat/aap-hook-integration) has a new AAP hook integration test that creates a Hook CR viaHook(aap_job_template_id=9). Without this wrapper change, it fails with:Confirmed by running the test against the current PyPI release (11.0.134).
Related Jira tickets
Polarion: MTV-781
Summary by CodeRabbit
aap), plusdeadline,image,playbook, andservice_account.spec.image/spec.playbook; serialization now follows the provided input parameters.imagedefaulting is conditional: it’s omitted whenaapis set, otherwise defaults apply.