progress: basic workflow execution from template.

This commit is contained in:
Andrey Melnikov
2020-04-08 16:42:32 -07:00
parent d4c919c9be
commit 02815b9cf0
4 changed files with 40 additions and 13 deletions

View File

@@ -293,7 +293,17 @@ func (c *Client) CreateWorkflowExecution(namespace string, workflow *WorkflowExe
(*opts.Labels)[workflowTemplateUIDLabelKey] = workflowTemplate.UID
(*opts.Labels)[workflowTemplateVersionLabelKey] = fmt.Sprint(workflowTemplate.Version)
//UX will prevent multiple workflows
workflows, err := UnmarshalWorkflows([]byte(workflowTemplate.Manifest), true)
manifest, err := workflowTemplate.GetWorkflowManifestBytes()
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"WorkflowTemplate": workflowTemplate,
"Error": err.Error(),
}).Error("Error with getting WorkflowManifest from workflow template")
return nil, err
}
workflows, err := UnmarshalWorkflows(manifest, true)
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
@@ -317,6 +327,17 @@ func (c *Client) CreateWorkflowExecution(namespace string, workflow *WorkflowExe
createdWorkflows = append(createdWorkflows, createdWorkflow)
}
if createdWorkflows == nil {
err = errors.New("unable to create workflow")
log.WithFields(log.Fields{
"Namespace": namespace,
"WorkflowTemplate": workflowTemplate,
"Error": err.Error(),
}).Error("Error parsing workflow.")
return nil, err
}
workflow.Name = createdWorkflows[0].Name
workflow.CreatedAt = createdWorkflows[0].CreationTimestamp.UTC()
workflow.UID = string(createdWorkflows[0].ObjectMeta.UID)