mirror of
				https://github.com/onepanelio/onepanel.git
				synced 2025-10-31 00:36:18 +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)[workflowTemplateUIDLabelKey] = workflowTemplate.UID | ||||||
| 	(*opts.Labels)[workflowTemplateVersionLabelKey] = fmt.Sprint(workflowTemplate.Version) | 	(*opts.Labels)[workflowTemplateVersionLabelKey] = fmt.Sprint(workflowTemplate.Version) | ||||||
| 	var testCWF wfv1.CronWorkflow | 	var argoCronWorkflow wfv1.CronWorkflow | ||||||
| 	testCWF.Spec.Schedule = cronWorkflow.Schedule | 	argoCronWorkflow.Spec.Schedule = cronWorkflow.Schedule | ||||||
| 	testCWF.Spec.Timezone = cronWorkflow.Timezone | 	argoCronWorkflow.Spec.Timezone = cronWorkflow.Timezone | ||||||
| 	testCWF.Spec.Suspend = cronWorkflow.Suspend | 	argoCronWorkflow.Spec.Suspend = cronWorkflow.Suspend | ||||||
| 	testCWF.Spec.ConcurrencyPolicy = wfv1.ConcurrencyPolicy(cronWorkflow.ConcurrencyPolicy) | 	argoCronWorkflow.Spec.ConcurrencyPolicy = wfv1.ConcurrencyPolicy(cronWorkflow.ConcurrencyPolicy) | ||||||
| 	testCWF.Spec.StartingDeadlineSeconds = cronWorkflow.StartingDeadlineSeconds | 	argoCronWorkflow.Spec.StartingDeadlineSeconds = cronWorkflow.StartingDeadlineSeconds | ||||||
| 	testCWF.Spec.SuccessfulJobsHistoryLimit = cronWorkflow.SuccessfulJobsHistoryLimit | 	argoCronWorkflow.Spec.SuccessfulJobsHistoryLimit = cronWorkflow.SuccessfulJobsHistoryLimit | ||||||
| 	testCWF.Spec.FailedJobsHistoryLimit = cronWorkflow.FailedJobsHistoryLimit | 	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 { | 		if err != nil { | ||||||
| 			log.WithFields(log.Fields{ | 			log.WithFields(log.Fields{ | ||||||
| 				"Namespace":    namespace, | 				"Namespace":    namespace, | ||||||
| @@ -60,7 +72,6 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow | |||||||
| 			}).Error("Error parsing workflow.") | 			}).Error("Error parsing workflow.") | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		cronWorkflow.Name = argoCreatedCronWorkflow.Name | 		cronWorkflow.Name = argoCreatedCronWorkflow.Name | ||||||
| 		cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC() | 		cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC() | ||||||
| 		cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID) | 		cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID) | ||||||
| @@ -69,6 +80,8 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow | |||||||
| 		cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = "" | 		cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = "" | ||||||
|  |  | ||||||
| 		return cronWorkflow, nil | 		return cronWorkflow, nil | ||||||
|  | 	} | ||||||
|  | 	return nil, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (c *Client) createCronWorkflow(namespace string, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (createdCronWorkflow *wfv1.CronWorkflow, err error) { | func (c *Client) createCronWorkflow(namespace string, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (createdCronWorkflow *wfv1.CronWorkflow, err error) { | ||||||
|   | |||||||
| @@ -63,5 +63,8 @@ func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.Cr | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | 	if cwf == nil { | ||||||
|  | 		return nil, nil | ||||||
|  | 	} | ||||||
| 	return apiCronWorkflow(cwf), nil | 	return apiCronWorkflow(cwf), nil | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aleksandr Melnikov
					Aleksandr Melnikov