This repository was archived by the owner on Oct 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
test/fixtures/all_resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ func TestGetAllResources(t *testing.T) {
8686 k8s .NewStatefulSet (),
8787 k8s .NewPodTemplate (),
8888 k8s .NewCronJob (),
89+ k8s .NewCronJobV1 (),
8990 k8s .NewServiceAccount (),
9091 k8s .NewService (),
9192 k8s .NewJob (),
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Namespace
3+ metadata :
4+ name : cronjob-v1
5+ ---
6+ apiVersion : batch/v1
7+ kind : CronJob
8+ metadata :
9+ name : cronjob-v1
10+ namespace : cronjob-v1
11+ spec :
12+ schedule : " */1 * * * *"
13+ jobTemplate :
14+ spec :
15+ template :
16+ spec :
17+ restartPolicy : OnFailure
18+ hostPID : true
19+ hostIPC : true
20+ hostNetwork : true
21+ containers :
22+ - name : container
23+ image : scratch
Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ func GetPodTemplateSpec(resource Resource) *PodTemplateSpecV1 {
111111 switch kubeType := resource .(type ) {
112112 case * CronJobV1Beta1 :
113113 return & kubeType .Spec .JobTemplate .Spec .Template
114+ case * CronJobV1 :
115+ return & kubeType .Spec .JobTemplate .Spec .Template
114116 case * DaemonSetV1 :
115117 return & kubeType .Spec .Template
116118 case * DeploymentV1 :
Original file line number Diff line number Diff line change @@ -127,6 +127,24 @@ func NewCronJob() *CronJobV1Beta1 {
127127 }
128128}
129129
130+ // NewCronJobV1 creates a new CronJob resource
131+ func NewCronJobV1 () * CronJobV1 {
132+ return & CronJobV1 {
133+ TypeMeta : TypeMetaV1 {
134+ Kind : "CronJob" ,
135+ APIVersion : "batch/v1" ,
136+ },
137+ ObjectMeta : ObjectMetaV1 {},
138+ Spec : CronJobSpecV1 {
139+ JobTemplate : JobTemplateSpecV1 {
140+ Spec : JobSpecV1 {
141+ Template : podTemplateSpec ,
142+ },
143+ },
144+ },
145+ }
146+ }
147+
130148// NewServiceAccount creates a new ServiceAccount resource
131149func NewServiceAccount () * ServiceAccountV1 {
132150 return & ServiceAccountV1 {
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ type CronJobV1Beta1 = batchv1beta1.CronJob
2525// CronJobSpecV1Beta1 is a type alias for the v1beta1 version of the k8s batch API.
2626type CronJobSpecV1Beta1 = batchv1beta1.CronJobSpec
2727
28+ // CronJobV1 is a type alias for the v1 version of the k8s batch API.
29+ type CronJobV1 = batchv1.CronJob
30+
31+ // CronJobSpecV1 is a type alias for the v1 version of the k8s batch API.
32+ type CronJobSpecV1 = batchv1.CronJobSpec
33+
2834// DaemonSetSpecV1 is a type alias for the v1 version of the k8s apps API.
2935type DaemonSetSpecV1 = appsv1.DaemonSetSpec
3036
@@ -40,6 +46,9 @@ type DeploymentV1 = appsv1.Deployment
4046// JobTemplateSpecV1Beta1 is a type alias for the v1beta1 version of the k8s batch API.
4147type JobTemplateSpecV1Beta1 = batchv1beta1.JobTemplateSpec
4248
49+ // JobTemplateSpecV1 is a type alias for the v1 version of the k8s batch API.
50+ type JobTemplateSpecV1 = batchv1.JobTemplateSpec
51+
4352// JobSpecV1 is a type alias for the v1 version of the k8s batch API.
4453type JobSpecV1 = batchv1.JobSpec
4554
You can’t perform that action at this time.
0 commit comments