-
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| import warnings | ||
|
|
||
| from ocp_resources.resource import NamespacedResource | ||
| from ocp_resources.utils.constants import TIMEOUT_4MINUTES | ||
|
|
||
| _UNSET = object() | ||
|
|
||
|
|
||
| class Hook(NamespacedResource): | ||
| """ | ||
|
|
@@ -13,8 +17,9 @@ def __init__( | |
| self, | ||
| name=None, | ||
| namespace=None, | ||
| image="quay.io/konveyor/hook-runner:latest", | ||
| image=_UNSET, | ||
| playbook=None, | ||
| aap_job_template_id=None, | ||
| client=None, | ||
| teardown=True, | ||
| yaml_file=None, | ||
|
|
@@ -25,6 +30,7 @@ def __init__( | |
| Args: | ||
| image (str): Path to an ansible image | ||
| playbook (str): Ansible playbook to be performed | ||
| aap_job_template_id (int): AAP/AWX job template ID to trigger during hook execution | ||
| """ | ||
| super().__init__( | ||
| name=name, | ||
|
|
@@ -35,15 +41,25 @@ def __init__( | |
| delete_timeout=delete_timeout, | ||
| **kwargs, | ||
| ) | ||
| if image is _UNSET: | ||
| warnings.warn( | ||
| "The default value for 'image' will be removed in the next release. Pass 'image' explicitly.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| image = "quay.io/konveyor/hook-runner:latest" if aap_job_template_id is None else None | ||
| self.image = image | ||
| self.playbook = playbook | ||
| self.aap_job_template_id = aap_job_template_id | ||
|
AmenB marked this conversation as resolved.
|
||
|
|
||
| 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, | ||
| }, | ||
| }) | ||
| self.res["spec"] = {} | ||
| _spec = self.res["spec"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i mean in other places, for new resources, we do not have the if-else option but let the api raise if a user passes mutually exlusive values, should we do it here as well?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we send what the caller passing us. |
||
| if self.aap_job_template_id is not None: | ||
|
AmenB marked this conversation as resolved.
|
||
| _spec["aap"] = {"jobTemplateId": self.aap_job_template_id} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @myakove I think that we should get here |
||
| else: | ||
|
AmenB marked this conversation as resolved.
|
||
| # TODO: remove else once image default is deprecated; use conditional assignment instead | ||
| _spec["image"] = self.image | ||
| _spec["playbook"] = self.playbook | ||
Uh oh!
There was an error while loading. Please reload this page.