mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-07 06:30:53 +08:00
Revert "Refactored CronWorkflow message."
This reverts commit 59cbf7d15e
.
This commit is contained in:
@@ -14,7 +14,8 @@ import (
|
||||
)
|
||||
|
||||
func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow *CronWorkflow) (*CronWorkflow, error) {
|
||||
workflowTemplate, err := c.GetWorkflowTemplate(namespace, cronWorkflow.WorkflowTemplate.UID, cronWorkflow.WorkflowTemplate.Version)
|
||||
workflow := cronWorkflow.WorkflowExecution
|
||||
workflowTemplate, err := c.GetWorkflowTemplate(namespace, workflow.WorkflowTemplate.UID, workflow.WorkflowTemplate.Version)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
@@ -28,7 +29,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
|
||||
opts := &WorkflowExecutionOptions{}
|
||||
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
|
||||
opts.GenerateName = strings.ToLower(re.ReplaceAllString(workflowTemplate.Name, `-`)) + "-"
|
||||
for _, param := range cronWorkflow.WorkflowExecutionParameters {
|
||||
for _, param := range workflow.Parameters {
|
||||
opts.Parameters = append(opts.Parameters, WorkflowExecutionParameter{
|
||||
Name: param.Name,
|
||||
Value: param.Value,
|
||||
@@ -53,7 +54,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
"CronWorkflow": cronWorkflow,
|
||||
"CronWorkflow": workflow,
|
||||
"Error": err.Error(),
|
||||
}).Error("Error parsing workflow.")
|
||||
return nil, err
|
||||
@@ -73,9 +74,9 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
|
||||
cronWorkflow.Name = argoCreatedCronWorkflow.Name
|
||||
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
|
||||
cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID)
|
||||
cronWorkflow.WorkflowTemplate = workflowTemplate
|
||||
cronWorkflow.WorkflowExecution.WorkflowTemplate = workflowTemplate
|
||||
// Manifests could get big, don't return them in this case.
|
||||
cronWorkflow.WorkflowTemplate.Manifest = ""
|
||||
cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = ""
|
||||
|
||||
return cronWorkflow, nil
|
||||
}
|
||||
@@ -83,7 +84,9 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
|
||||
}
|
||||
|
||||
func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow) (*CronWorkflow, error) {
|
||||
workflowTemplate, err := c.GetWorkflowTemplate(namespace, cronWorkflow.WorkflowTemplate.UID, cronWorkflow.WorkflowTemplate.Version)
|
||||
|
||||
workflow := cronWorkflow.WorkflowExecution
|
||||
workflowTemplate, err := c.GetWorkflowTemplate(namespace, workflow.WorkflowTemplate.UID, workflow.WorkflowTemplate.Version)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
@@ -97,7 +100,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
opts := &WorkflowExecutionOptions{}
|
||||
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
|
||||
opts.GenerateName = strings.ToLower(re.ReplaceAllString(workflowTemplate.Name, `-`)) + "-"
|
||||
for _, param := range cronWorkflow.WorkflowExecutionParameters {
|
||||
for _, param := range workflow.Parameters {
|
||||
opts.Parameters = append(opts.Parameters, WorkflowExecutionParameter{
|
||||
Name: param.Name,
|
||||
Value: param.Value,
|
||||
@@ -122,7 +125,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
"CronWorkflow": cronWorkflow,
|
||||
"CronWorkflow": workflow,
|
||||
"Error": err.Error(),
|
||||
}).Error("Error parsing workflow.")
|
||||
return nil, err
|
||||
@@ -142,9 +145,9 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
cronWorkflow.Name = argoCreatedCronWorkflow.Name
|
||||
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
|
||||
cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID)
|
||||
cronWorkflow.WorkflowTemplate = workflowTemplate
|
||||
cronWorkflow.WorkflowExecution.WorkflowTemplate = workflowTemplate
|
||||
// Manifests could get big, don't return them in this case.
|
||||
cronWorkflow.WorkflowTemplate.Manifest = ""
|
||||
cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = ""
|
||||
|
||||
return cronWorkflow, nil
|
||||
}
|
||||
@@ -173,6 +176,7 @@ func (c *Client) GetCronWorkflow(namespace, name string) (cronWorkflow *CronWork
|
||||
StartingDeadlineSeconds: cwf.Spec.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: cwf.Spec.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: cwf.Spec.FailedJobsHistoryLimit,
|
||||
WorkflowExecution: nil,
|
||||
}
|
||||
|
||||
return
|
||||
@@ -207,6 +211,7 @@ func (c *Client) ListCronWorkflows(namespace string) (cronWorkflows []*CronWorkf
|
||||
StartingDeadlineSeconds: cwf.Spec.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: cwf.Spec.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: cwf.Spec.FailedJobsHistoryLimit,
|
||||
WorkflowExecution: nil,
|
||||
})
|
||||
}
|
||||
return
|
||||
|
Reference in New Issue
Block a user