Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions ocp_resources/controller_revision.py
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You specify that the code expect int64 but in the code you convert it to int64
We need to get it from the user and only validate that the user was sent us int64

"""
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}
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ python-benedict = "^0.32.0"
packaging = "^23.1"
python-simple-logger = "^1.0.6"
jinja2 = "^3.1.2"
numpy = "*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not edit this file directly, use poetry add