diff --git a/ocp_resources/controller_revision.py b/ocp_resources/controller_revision.py index bfd489fbf1..64a1f21b2a 100644 --- a/ocp_resources/controller_revision.py +++ b/ocp_resources/controller_revision.py @@ -1,42 +1,42 @@ -# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/ -from ocp_resources.constants import TIMEOUT_4MINUTES +import numpy + from ocp_resources.resource import NamespacedResource class ControllerRevision(NamespacedResource): + """ + https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/ + """ + api_group = NamespacedResource.ApiGroup.APPS def __init__( self, - name=None, - namespace=None, - client=None, - teardown=True, - timeout=TIMEOUT_4MINUTES, - privileged_client=None, - yaml_file=None, - delete_timeout=TIMEOUT_4MINUTES, owner_references=None, revision_object=None, + revision=None, **kwargs, ): - super().__init__( - name=name, - namespace=namespace, - client=client, - teardown=teardown, - timeout=timeout, - privileged_client=privileged_client, - yaml_file=yaml_file, - delete_timeout=delete_timeout, - **kwargs, - ) + """ + Args: + owner_references (list, optional): List of objects depended on this object. + revision_object (object, optional): the Data Object representing the state. + revision (int64): indicates the revision of the state represented by Data. + """ + super().__init__(**kwargs) self.owner_references = owner_references self.revision_object = revision_object + self.revision = numpy.int64(revision) def to_dict(self): super().to_dict() if not self.yaml_file: + if not self.revision: + raise ValueError( + "Passing yaml_file or parameter 'revision' is required." + ) + self.res.update({"revision": self.revision}) + if self.owner_references: self.res.setdefault("metadata", {}).update( {"ownerReference": self.owner_references} diff --git a/pyproject.toml b/pyproject.toml index 0da815493a..e873661af1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,3 +64,4 @@ python-benedict = "^0.32.0" packaging = "^23.1" python-simple-logger = "^1.0.6" jinja2 = "^3.1.2" +numpy = "*"