Skip to content

Commit 45e23d6

Browse files
authored
feat: Add support for volumes in job resource (#2509)
* support token creation for service account * updated doc strings etc. * address review comments * feat: Add support for volumes in job resource
1 parent 5aa740f commit 45e23d6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ocp_resources/job.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Job(NamespacedResource):
2323
deleted (for example the pods left behind when you delete a Job). Options are: "Background",
2424
"Foreground" and "Orphan". Read more here:
2525
https://kubernetes.io/docs/concepts/architecture/garbage-collection/#cascading-deletion
26+
volumes (list): List of volumes that can be mounted by containers belonging to the pod
2627
"""
2728

2829
api_group = NamespacedResource.ApiGroup.BATCH
@@ -43,6 +44,7 @@ def __init__(
4344
service_account=None,
4445
containers=None,
4546
background_propagation_policy=None,
47+
volumes=None,
4648
**kwargs,
4749
):
4850
super().__init__(
@@ -59,6 +61,7 @@ def __init__(
5961
self.service_account = service_account
6062
self.containers = containers
6163
self.background_propagation_policy = background_propagation_policy
64+
self.volumes = volumes
6265

6366
def to_dict(self) -> None:
6467
super().to_dict()
@@ -78,6 +81,9 @@ def to_dict(self) -> None:
7881
if self.restart_policy:
7982
self.res["spec"]["template"]["spec"]["restartPolicy"] = self.restart_policy
8083

84+
if self.volumes:
85+
self.res["spec"]["template"]["spec"]["volumes"] = self.volumes
86+
8187
def delete(self, wait=False, timeout=TIMEOUT_4MINUTES, body=None):
8288
"""
8389
Delete Job object

0 commit comments

Comments
 (0)