-
Notifications
You must be signed in to change notification settings - Fork 77
feat: add aap_job_template_id support to Hook class #2759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AmenB
wants to merge
1
commit into
RedHatQE:main
Choose a base branch
from
AmenB:feat/hook-aap-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−39
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,42 @@ | ||
| from ocp_resources.resource import NamespacedResource | ||
| from ocp_resources.utils.constants import TIMEOUT_4MINUTES | ||
| import warnings | ||
| from typing import Any | ||
|
|
||
| from ocp_resources._hook_generated import Hook as _GeneratedHook | ||
|
|
||
| class Hook(NamespacedResource): | ||
| """ | ||
| Migration Tool for Virtualization (MTV) Plan's Hook Resource. | ||
| _UNSET = object() | ||
| _DEFAULT_IMAGE = "quay.io/konveyor/hook-runner:latest" | ||
|
|
||
|
|
||
| class Hook(_GeneratedHook): | ||
| """ | ||
| Deprecated shim for backward compatibility. | ||
|
|
||
| api_group = NamespacedResource.ApiGroup.FORKLIFT_KONVEYOR_IO | ||
| Preserves the legacy default-image behavior. New code should use | ||
| ``from ocp_resources._hook_generated import Hook`` directly. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| name=None, | ||
| namespace=None, | ||
| image="quay.io/konveyor/hook-runner:latest", | ||
| playbook=None, | ||
| client=None, | ||
| teardown=True, | ||
| yaml_file=None, | ||
| delete_timeout=TIMEOUT_4MINUTES, | ||
| **kwargs, | ||
| ): | ||
| """ | ||
| Args: | ||
| image (str): Path to an ansible image | ||
| playbook (str): Ansible playbook to be performed | ||
| """ | ||
| aap: dict[str, Any] | None = None, | ||
| deadline: int | None = None, | ||
| image: Any = _UNSET, | ||
| playbook: str | None = None, | ||
| service_account: str | None = None, | ||
| **kwargs: Any, | ||
| ) -> None: | ||
| 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__( | ||
| name=name, | ||
| namespace=namespace, | ||
| client=client, | ||
| teardown=teardown, | ||
| yaml_file=yaml_file, | ||
| delete_timeout=delete_timeout, | ||
| aap=aap, | ||
| deadline=deadline, | ||
| image=image, | ||
| playbook=playbook, | ||
| service_account=service_account, | ||
| **kwargs, | ||
| ) | ||
| self.image = image | ||
| self.playbook = playbook | ||
|
|
||
| def to_dict(self) -> None: | ||
| super().to_dict() | ||
| if not self.kind_dict and not self.yaml_file: | ||
| self.res.update({ | ||
| "spec": { | ||
| "image": self.image, | ||
| "playbook": self.playbook, | ||
| }, | ||
| }) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Move the deprecation warning inside the unset check and add the missing TODO.
Currently, the
DeprecationWarningis emitted unconditionally. As pointed out in previous reviews, this means callers who explicitly passimage="quay.io/konveyor/hook-runner:latest"(or any other image) will still receive a warning instructing them to passimage=, which they already did. Additionally, the requested TODO comment to remove the fallback is missing.Move the warning inside the
if image is _UNSET:block to only warn when the legacy default behavior is invoked, and add the TODO comment.💡 Proposed fix
🤖 Prompt for AI Agents