Skip to content
Merged
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
9 changes: 0 additions & 9 deletions ocp_resources/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def __init__(
name=None,
client=None,
teardown=True,
label=None,
yaml_file=None,
delete_timeout=TIMEOUT_4MINUTES,
**kwargs,
Expand All @@ -30,11 +29,3 @@ def __init__(
delete_timeout=delete_timeout,
**kwargs,
)
self.label = label

def to_dict(self):
super().to_dict()
if not self.yaml_file and self.label:
self.res.setdefault("metadata", {}).setdefault("labels", {}).update(
self.label
)
7 changes: 7 additions & 0 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def __init__(
node_selector_labels=None,
config_file=None,
context=None,
label=None,
timeout_seconds=TIMEOUT_1MINUTE,
):
"""
Expand All @@ -338,6 +339,7 @@ def __init__(
config_file (str): Path to config file for connecting to remote cluster.
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

"""
if not self.api_group and not self.api_version:
Expand All @@ -352,6 +354,7 @@ def __init__(
self.resource_dict = None # Filled in case yaml_file is not None
self.config_file = config_file
self.context = context
self.label = label
if not (self.name or self.yaml_file):
raise ValueError("name or yaml file is required")

Expand Down Expand Up @@ -412,6 +415,10 @@ def _base_body(self):
"kind": self.kind,
"metadata": {"name": self.name},
}
if self.label:
self.res.setdefault("metadata", {}).setdefault("labels", {}).update(
self.label
)

def to_dict(self):
"""
Expand Down