mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-23 13:33:44 +08:00
create workflow by template reference
This commit is contained in:
@@ -8,6 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (r *ResourceManager) CreateWorkflow(namespace string, workflow *model.Workflow) (createdWorkflow *model.Workflow, err error) {
|
func (r *ResourceManager) CreateWorkflow(namespace string, workflow *model.Workflow) (createdWorkflow *model.Workflow, err error) {
|
||||||
|
workflowTemplate, err := r.workflowRepository.GetWorkflowTemplate(workflow.WorkflowTemplate.UID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, util.NewUserError(codes.NotFound, "Workflow template not found.")
|
||||||
|
}
|
||||||
|
|
||||||
opts := &argo.Options{
|
opts := &argo.Options{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
}
|
}
|
||||||
@@ -18,7 +23,7 @@ func (r *ResourceManager) CreateWorkflow(namespace string, workflow *model.Workf
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
createdWorkflows, err := r.argClient.Create(workflow.WorkflowTemplate.GetManifestBytes(), opts)
|
createdWorkflows, err := r.argClient.Create(workflowTemplate.GetManifestBytes(), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ func NewWorkflowServer(resourceManager *manager.ResourceManager) *WorkflowServer
|
|||||||
func (s *WorkflowServer) CreateWorkflow(ctx context.Context, req *api.CreateWorkflowRequest) (*api.Workflow, error) {
|
func (s *WorkflowServer) CreateWorkflow(ctx context.Context, req *api.CreateWorkflowRequest) (*api.Workflow, error) {
|
||||||
workflow := &model.Workflow{
|
workflow := &model.Workflow{
|
||||||
WorkflowTemplate: model.WorkflowTemplate{
|
WorkflowTemplate: model.WorkflowTemplate{
|
||||||
Manifest: req.Workflow.WorkflowTemplate.Manifest,
|
UID: req.Workflow.WorkflowTemplate.Uid,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, param := range req.Workflow.Parameters {
|
for _, param := range req.Workflow.Parameters {
|
||||||
|
Reference in New Issue
Block a user