Skip to content

Commit

Permalink
pwx:40447: add job update util
Browse files Browse the repository at this point in the history
Signed-off-by: strivedi-px <[email protected]>
  • Loading branch information
strivedi-px committed Dec 6, 2024
1 parent f060bab commit f4e73b9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions k8s/batch/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f4e73b9

Please sign in to comment.