1
0
mirror of https://github.com/rancher/types.git synced 2025-08-14 18:52:59 +00:00

Embed jobtempalte for cron job

This commit is contained in:
Alena Prokharchyk 2018-02-20 15:56:34 -08:00
parent eab18ee4b9
commit 0e7b5e7a5d

View File

@ -281,6 +281,13 @@ func jobTypes(schemas *types.Schemas) *types.Schemas {
func cronJobTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, batchv1beta1.JobTemplateSpec{},
&m.Move{
From: "metadata",
To: "jobMetadata",
},
&m.Embed{Field: "spec"},
).
AddMapperForType(&Version, batchv1beta1.CronJobSpec{},
&m.Move{
From: "schedule",
@ -306,22 +313,34 @@ func cronJobTypes(schemas *types.Schemas) *types.Schemas {
From: "failedJobsHistoryLimit",
To: "cronJob/failedJobsHistoryLimit",
},
// TODO - embed jobTemplate field. Now it fails due to jobTemplate.spec and jobTemplate.spec.template.spec
// name conflict
&m.Move{
From: "jobTemplate",
To: "cronJob/jobTemplate",
&m.Embed{
Field: "jobTemplate",
},
&m.Move{
From: "job",
To: "cronJob/job",
},
&m.Move{
From: "jobMetadata/labels",
To: "cronJob/jobLabels",
NoDeleteFromField: true,
},
&m.Move{
From: "jobMetadata/annotations",
To: "cronJob/jobAnnotations",
NoDeleteFromField: true,
},
&m.Drop{Field: "jobMetadata"},
).
AddMapperForType(&Version, batchv1beta1.CronJob{},
&m.Move{
From: "status",
To: "cronJobStatus",
},
// TODO resolve once proper embedding for jobTemplate is done
//NewWorkloadTypeMapper(),
NewWorkloadTypeMapper(),
).
MustImport(&Version, batchv1beta1.CronJobSpec{}, cronJobOverride{}).
MustImport(&Version, batchv1beta1.JobTemplateSpec{}).
MustImportAndCustomize(&Version, batchv1beta1.CronJob{}, func(schema *types.Schema) {
schema.BaseType = "workload"
}, projectOverride{})