From f4e73b988db85b8659e915edee223990c7353907 Mon Sep 17 00:00:00 2001 From: strivedi-px Date: Fri, 6 Dec 2024 15:48:58 +0530 Subject: [PATCH] pwx:40447: add job update util Signed-off-by: strivedi-px --- k8s/batch/jobs.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/k8s/batch/jobs.go b/k8s/batch/jobs.go index 4187cac2..95e6d940 100644 --- a/k8s/batch/jobs.go +++ b/k8s/batch/jobs.go @@ -18,6 +18,8 @@ type JobOps interface { GetJob(name, namespace string) (*batchv1.Job, error) // DeleteJob deletes the job with given namespace and name DeleteJob(name, namespace string) error + // UpdateJob updates the given job + UpdateJob(job *batchv1.Job) (*batchv1.Job, error) // DeleteJobWithForce deletes the job with given namespace and name DeleteJobWithForce(name, namespace string) error // ValidateJob validates if the job with given namespace and name succeeds. @@ -56,6 +58,14 @@ func (c *Client) DeleteJob(name, namespace string) error { }) } +// UpdateJob updates the given job. +func (c *Client) UpdateJob(job *batchv1.Job) (*batchv1.Job, error) { + if err := c.initClient(); err != nil { + return nil, err + } + return c.batch.Jobs(job.Namespace).Update(context.TODO(), job, metav1.UpdateOptions{}) +} + // DeleteJobWithForce deletes the job with given namespace and name with force option func (c *Client) DeleteJobWithForce(name, namespace string) error { if err := c.initClient(); err != nil {