mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 13:46:51 +08:00
Refactored CronWorkflow message.
- Moved Parameters to it's own field - Using WorkflowTemplate directly, instead of nesting it inside of WorkflowExecution. - Updated related code to use new structure.
This commit is contained in:
@@ -37,8 +37,8 @@ func apiCronWorkflow(cwf *v1.CronWorkflow) (cronWorkflow *api.CronWorkflow) {
|
||||
cronWorkflow.FailedJobsHistoryLimit = *cwf.FailedJobsHistoryLimit
|
||||
}
|
||||
|
||||
if cwf.WorkflowExecution != nil {
|
||||
cronWorkflow.WorkflowExecution = GenApiWorkflowExecution(cwf.WorkflowExecution)
|
||||
if cwf.WorkflowTemplate != nil {
|
||||
cronWorkflow.WorkflowTemplate = GenApiWorkflowTemplate(cwf.WorkflowTemplate)
|
||||
}
|
||||
|
||||
return
|
||||
@@ -51,28 +51,29 @@ func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.Cr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
workflow := &v1.WorkflowExecution{
|
||||
WorkflowTemplate: &v1.WorkflowTemplate{
|
||||
UID: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Uid,
|
||||
Version: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Version,
|
||||
},
|
||||
workflowTemplate := &v1.WorkflowTemplate{
|
||||
UID: req.CronWorkflow.WorkflowTemplate.Uid,
|
||||
Version: req.CronWorkflow.WorkflowTemplate.Version,
|
||||
}
|
||||
for _, param := range req.CronWorkflow.WorkflowExecution.Parameters {
|
||||
workflow.Parameters = append(workflow.Parameters, v1.WorkflowExecutionParameter{
|
||||
|
||||
var workflowExecutionParams []*v1.WorkflowExecutionParameter
|
||||
for _, param := range req.CronWorkflow.Parameters {
|
||||
workflowExecutionParams = append(workflowExecutionParams, &v1.WorkflowExecutionParameter{
|
||||
Name: param.Name,
|
||||
Value: ptr.String(param.Value),
|
||||
})
|
||||
}
|
||||
|
||||
cronWorkflow := v1.CronWorkflow{
|
||||
Schedule: req.CronWorkflow.Schedule,
|
||||
Timezone: req.CronWorkflow.Timezone,
|
||||
Suspend: req.CronWorkflow.Suspend,
|
||||
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
|
||||
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
|
||||
WorkflowExecution: workflow,
|
||||
Schedule: req.CronWorkflow.Schedule,
|
||||
Timezone: req.CronWorkflow.Timezone,
|
||||
Suspend: req.CronWorkflow.Suspend,
|
||||
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
|
||||
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
|
||||
WorkflowExecutionParameters: workflowExecutionParams,
|
||||
WorkflowTemplate: workflowTemplate,
|
||||
}
|
||||
|
||||
cwf, err := client.CreateCronWorkflow(req.Namespace, &cronWorkflow)
|
||||
@@ -91,28 +92,29 @@ func (c *CronWorkflowServer) UpdateCronWorkflow(ctx context.Context, req *api.Up
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
}
|
||||
workflow := &v1.WorkflowExecution{
|
||||
WorkflowTemplate: &v1.WorkflowTemplate{
|
||||
UID: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Uid,
|
||||
Version: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Version,
|
||||
},
|
||||
workflowTemplate := &v1.WorkflowTemplate{
|
||||
UID: req.CronWorkflow.WorkflowTemplate.Uid,
|
||||
Version: req.CronWorkflow.WorkflowTemplate.Version,
|
||||
}
|
||||
for _, param := range req.CronWorkflow.WorkflowExecution.Parameters {
|
||||
workflow.Parameters = append(workflow.Parameters, v1.WorkflowExecutionParameter{
|
||||
|
||||
var workflowExecutionParams []*v1.WorkflowExecutionParameter
|
||||
for _, param := range req.CronWorkflow.Parameters {
|
||||
workflowExecutionParams = append(workflowExecutionParams, &v1.WorkflowExecutionParameter{
|
||||
Name: param.Name,
|
||||
Value: ptr.String(param.Value),
|
||||
})
|
||||
}
|
||||
|
||||
cronWorkflow := v1.CronWorkflow{
|
||||
Schedule: req.CronWorkflow.Schedule,
|
||||
Timezone: req.CronWorkflow.Timezone,
|
||||
Suspend: req.CronWorkflow.Suspend,
|
||||
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
|
||||
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
|
||||
WorkflowExecution: workflow,
|
||||
Schedule: req.CronWorkflow.Schedule,
|
||||
Timezone: req.CronWorkflow.Timezone,
|
||||
Suspend: req.CronWorkflow.Suspend,
|
||||
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
|
||||
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
|
||||
WorkflowExecutionParameters: workflowExecutionParams,
|
||||
WorkflowTemplate: workflowTemplate,
|
||||
}
|
||||
|
||||
cwf, err := client.UpdateCronWorkflow(req.Namespace, req.Name, &cronWorkflow)
|
||||
|
Reference in New Issue
Block a user