Fix cronjob structure
This commit is contained in:
@@ -1,25 +1,32 @@
|
|||||||
package helm
|
package helm
|
||||||
|
|
||||||
|
type CronTab struct {
|
||||||
|
*K8sBase `yaml:",inline"`
|
||||||
|
Spec CronSpec `yaml:"spec"`
|
||||||
|
}
|
||||||
|
type CronSpec struct {
|
||||||
|
Schedule string `yaml:"schedule"`
|
||||||
|
JobTemplate JobTemplate `yaml:"jobTemplate"`
|
||||||
|
}
|
||||||
|
type JobTemplate struct {
|
||||||
|
Spec JobSpecDescription `yaml:"spec"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JobSpecDescription struct {
|
||||||
|
Template JobSpecTemplate `yaml:"template"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JobSpecTemplate struct {
|
||||||
|
Metadata Metadata `yaml:"metadata"`
|
||||||
|
Spec Job `yaml:"spec"`
|
||||||
|
}
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
ServiceAccount string `yaml:"serviceAccount,omitempty"`
|
ServiceAccount string `yaml:"serviceAccount,omitempty"`
|
||||||
ServiceAccountName string `yaml:"serviceAccountName,omitempty"`
|
ServiceAccountName string `yaml:"serviceAccountName,omitempty"`
|
||||||
Containers []Container `yaml:"containers"`
|
Containers []Container `yaml:"containers"`
|
||||||
RestartPolicy string `yaml:"restartPolicy,omitempty"`
|
RestartPolicy string `yaml:"restartPolicy,omitempty"`
|
||||||
}
|
}
|
||||||
type JobSpec struct {
|
|
||||||
Template Job `yaml:"template"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type JobTemplate struct {
|
|
||||||
Metadata Metadata `yaml:"metadata"`
|
|
||||||
Spec JobSpec `yaml:"spec"`
|
|
||||||
Schedule string `yaml:"schedule"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CronTab struct {
|
|
||||||
*K8sBase `yaml:",inline"`
|
|
||||||
JobTemplate JobTemplate `yaml:"jobTemplate"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCrontab(name, image, command, schedule string, serviceAccount *ServiceAccount) *CronTab {
|
func NewCrontab(name, image, command, schedule string, serviceAccount *ServiceAccount) *CronTab {
|
||||||
cron := &CronTab{
|
cron := &CronTab{
|
||||||
@@ -35,25 +42,21 @@ func NewCrontab(name, image, command, schedule string, serviceAccount *ServiceAc
|
|||||||
|
|
||||||
cron.K8sBase.Metadata.Name = ReleaseNameTpl + "-" + name
|
cron.K8sBase.Metadata.Name = ReleaseNameTpl + "-" + name
|
||||||
cron.K8sBase.Metadata.Labels[K+"/component"] = name
|
cron.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||||
cron.JobTemplate = JobTemplate{
|
cron.Spec.Schedule = schedule
|
||||||
Schedule: schedule,
|
cron.Spec.JobTemplate.Spec.Template.Metadata = Metadata{
|
||||||
Metadata: Metadata{
|
Labels: cron.K8sBase.Metadata.Labels,
|
||||||
Labels: cron.K8sBase.Metadata.Labels,
|
}
|
||||||
},
|
cron.Spec.JobTemplate.Spec.Template.Spec = Job{
|
||||||
Spec: JobSpec{
|
ServiceAccount: serviceAccount.Name(),
|
||||||
Template: Job{
|
ServiceAccountName: serviceAccount.Name(),
|
||||||
ServiceAccount: serviceAccount.Name(),
|
Containers: []Container{
|
||||||
ServiceAccountName: serviceAccount.Name(),
|
{
|
||||||
Containers: []Container{
|
Name: name,
|
||||||
{
|
Image: image,
|
||||||
Name: name,
|
Command: []string{command},
|
||||||
Image: image,
|
|
||||||
Command: []string{command},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: "OnFailure",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
RestartPolicy: "OnFailure",
|
||||||
}
|
}
|
||||||
|
|
||||||
return cron
|
return cron
|
||||||
|
Reference in New Issue
Block a user