mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-11-01 17:22:32 +08:00
Renaming variable testCWF.
Adding the workflow spec correctly to the CronWorkflow spec.
This commit is contained in:
@@ -42,16 +42,28 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
}
|
||||
(*opts.Labels)[workflowTemplateUIDLabelKey] = workflowTemplate.UID
|
||||
(*opts.Labels)[workflowTemplateVersionLabelKey] = fmt.Sprint(workflowTemplate.Version)
|
||||
var testCWF wfv1.CronWorkflow
|
||||
testCWF.Spec.Schedule = cronWorkflow.Schedule
|
||||
testCWF.Spec.Timezone = cronWorkflow.Timezone
|
||||
testCWF.Spec.Suspend = cronWorkflow.Suspend
|
||||
testCWF.Spec.ConcurrencyPolicy = wfv1.ConcurrencyPolicy(cronWorkflow.ConcurrencyPolicy)
|
||||
testCWF.Spec.StartingDeadlineSeconds = cronWorkflow.StartingDeadlineSeconds
|
||||
testCWF.Spec.SuccessfulJobsHistoryLimit = cronWorkflow.SuccessfulJobsHistoryLimit
|
||||
testCWF.Spec.FailedJobsHistoryLimit = cronWorkflow.FailedJobsHistoryLimit
|
||||
var argoCronWorkflow wfv1.CronWorkflow
|
||||
argoCronWorkflow.Spec.Schedule = cronWorkflow.Schedule
|
||||
argoCronWorkflow.Spec.Timezone = cronWorkflow.Timezone
|
||||
argoCronWorkflow.Spec.Suspend = cronWorkflow.Suspend
|
||||
argoCronWorkflow.Spec.ConcurrencyPolicy = wfv1.ConcurrencyPolicy(cronWorkflow.ConcurrencyPolicy)
|
||||
argoCronWorkflow.Spec.StartingDeadlineSeconds = cronWorkflow.StartingDeadlineSeconds
|
||||
argoCronWorkflow.Spec.SuccessfulJobsHistoryLimit = cronWorkflow.SuccessfulJobsHistoryLimit
|
||||
argoCronWorkflow.Spec.FailedJobsHistoryLimit = cronWorkflow.FailedJobsHistoryLimit
|
||||
//UX prevents multiple workflows
|
||||
workflows, err := UnmarshalWorkflows([]byte(workflowTemplate.Manifest), true)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
"CronWorkflow": workflow,
|
||||
"Error": err.Error(),
|
||||
}).Error("Error parsing workflow.")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
argoCreatedCronWorkflow, err := c.createCronWorkflow(namespace, &testCWF, opts)
|
||||
for _, wf := range workflows {
|
||||
argoCronWorkflow.Spec.WorkflowSpec = wf.Spec
|
||||
argoCreatedCronWorkflow, err := c.createCronWorkflow(namespace, &argoCronWorkflow, opts)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
@@ -60,7 +72,6 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
}).Error("Error parsing workflow.")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cronWorkflow.Name = argoCreatedCronWorkflow.Name
|
||||
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
|
||||
cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID)
|
||||
@@ -70,6 +81,8 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
|
||||
return cronWorkflow, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *Client) createCronWorkflow(namespace string, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (createdCronWorkflow *wfv1.CronWorkflow, err error) {
|
||||
if opts == nil {
|
||||
|
||||
@@ -63,5 +63,8 @@ func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.Cr
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cwf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return apiCronWorkflow(cwf), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user