...
1 package generator
2
3 import (
4 batchv1 "k8s.io/api/batch/v1"
5 corev1 "k8s.io/api/core/v1"
6 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7 )
8
9 type JobParams struct {
10 TypeMeta metav1.TypeMeta
11 ObjectMeta metav1.ObjectMeta
12 PodTemplateSpec corev1.PodTemplateSpec
13 SpecParams JobSpecParams
14 }
15 type JobSpecParams struct {
16 CompletionMode *batchv1.CompletionMode
17 TTLSecondsAfterFinished *int32
18 BackOffLimit *int32
19 Parallelism *int32
20 Completion *int32
21 ActiveDeadlineSeconds *int64
22 }
23
24 func GetJob(jobParams JobParams) batchv1.Job {
25 return batchv1.Job{
26 TypeMeta: jobParams.TypeMeta,
27 ObjectMeta: jobParams.ObjectMeta,
28 Spec: batchv1.JobSpec{
29 Template: jobParams.PodTemplateSpec,
30 Parallelism: jobParams.SpecParams.Parallelism,
31 Completions: jobParams.SpecParams.Completion,
32 ActiveDeadlineSeconds: jobParams.SpecParams.ActiveDeadlineSeconds,
33 BackoffLimit: jobParams.SpecParams.BackOffLimit,
34
35 TTLSecondsAfterFinished: jobParams.SpecParams.TTLSecondsAfterFinished,
36 CompletionMode: jobParams.SpecParams.CompletionMode,
37 },
38 }
39
40 }
41
View as plain text