Skip to content

Commit

Permalink
Add support for annotations in Resource (#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfo-ab committed Jun 28, 2024
1 parent 2692eab commit 1782f90
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def __init__(
config_dict: Dict[str, Any] | None = None,
context: str = "",
label: Dict[str, str] | None = None,
annotations: Dict[str, str] | None = None,
timeout_seconds: int = TIMEOUT_1MINUTE,
api_group: str = "",
hash_log_data: bool = True,
Expand All @@ -393,6 +394,7 @@ def __init__(
context (str): Context name for connecting to remote cluster.
timeout_seconds (int): timeout for a get api call, call out be terminated after this many seconds
label (dict): Resource labels
annotations (Dict[str, str] | None): Resource annotations
api_group (str): Resource API group; will overwrite API group definition in resource class
hash_log_data (bool): Hash resource content based on resource keys_to_hash property
(example: Secret resource)
Expand All @@ -417,6 +419,7 @@ def __init__(
self.config_dict = config_dict or {}
self.context = context
self.label = label
self.annotations = annotations
self.timeout_seconds = timeout_seconds
self.client: DynamicClient = client or get_client(config_file=self.config_file, context=self.context)
self.api_group: str = api_group or self.api_group
Expand Down Expand Up @@ -494,6 +497,8 @@ def _base_body(self) -> None:
}
if self.label:
self.res.setdefault("metadata", {}).setdefault("labels", {}).update(self.label)
if self.annotations:
self.res.setdefault("metadata", {}).setdefault("annotations", {}).update(self.annotations)

def to_dict(self) -> None:
"""
Expand Down

0 comments on commit 1782f90

Please sign in to comment.