Skip to content

Commit

Permalink
clean_up, add timeout arg (#2069)
Browse files Browse the repository at this point in the history
* clean_up, add `timeout` arg

* Remove clean_up from Project
  • Loading branch information
myakove committed Aug 23, 2024
1 parent b3dd3c6 commit bf45869
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions ocp_resources/project.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from warnings import warn

from ocp_resources.project_project_openshift_io import Project # noqa: F401
from ocp_resources.project_project_openshift_io import Project, ProjectRequest # noqa: F401


warn(
f"The module {__name__} is deprecated and will be removed in version 4.17, "
"`Project` should be either imported from `ocp_resources.project_project_openshift_io` or "
"`ocp_resources.project_config_openshift_io` depending on the API group.",
"`ocp_resources.project_config_openshift_io` depending on the API group."
"`ProjectRequest` should be imported from `ocp_resources.project_project_openshift_io`",
DeprecationWarning,
stacklevel=2,
)
4 changes: 2 additions & 2 deletions ocp_resources/project_project_openshift_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ def to_dict(self) -> None:
if self.display_name:
self.res["displayName"] = self.display_name

def clean_up(self, wait: bool = True) -> bool:
return Project(name=self.name).delete(wait=wait)
def clean_up(self, wait: bool = True, timeout: Optional[int] = None) -> bool:
return Project(name=self.name).clean_up(wait=wait, timeout=timeout)
5 changes: 3 additions & 2 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,14 @@ def deploy(self, wait: bool = False) -> "Resource":
self.create(wait=wait)
return self

def clean_up(self, wait: bool = True) -> bool:
def clean_up(self, wait: bool = True, timeout: Optional[int] = None) -> bool:
"""
For debug, export SKIP_RESOURCE_TEARDOWN to skip resource teardown.
Spaces are important in the export dict
Args:
wait (bool, optional): Wait for resource deletion. Defaults to True.
timeout (int, optional): Timeout in seconds to wait for resource to be deleted. Defaults to 240.
Returns:
bool: True if resource was deleted else False.
Expand Down Expand Up @@ -594,7 +595,7 @@ def clean_up(self, wait: bool = True) -> bool:
)
return False

return self.delete(wait=wait, timeout=self.delete_timeout)
return self.delete(wait=wait, timeout=timeout or self.delete_timeout)

@classmethod
def _prepare_resources(
Expand Down

0 comments on commit bf45869

Please sign in to comment.