diff --git a/entrypoint.go b/entrypoint.go index a45af6a..65def07 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -247,15 +247,17 @@ func ToScheduler(m interface{}) (n *workflow_execution.WorkflowSchedule) { } func (r *Request) Schedule(wfID string, scheduler *workflow_execution.WorkflowSchedule) (*workflow_execution.WorkflowSchedule, error) { - if _, _, err := scheduler.Schedules(wfID, &tools.APIRequest{ + ws, _, _, err := scheduler.Schedules(wfID, &tools.APIRequest{ Caller: r.caller, Username: r.user, PeerID: r.peerID, Groups: r.groups, - }); err != nil { + }) + if err != nil { return nil, err } - return scheduler, nil + fmt.Println("BAM", ws) + return ws, nil } func (r *Request) CheckBooking(wfID string, start string, end string, durationInS float64, cron string) bool { diff --git a/models/workflow_execution/workflow_scheduler.go b/models/workflow_execution/workflow_scheduler.go index b5727a7..852b2b4 100644 --- a/models/workflow_execution/workflow_scheduler.go +++ b/models/workflow_execution/workflow_scheduler.go @@ -87,21 +87,21 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest) return true, wf, execs, nil } -func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (*workflow.Workflow, []*WorkflowExecutions, error) { +func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (*WorkflowSchedule, *workflow.Workflow, []*WorkflowExecutions, error) { if request == nil { - return nil, []*WorkflowExecutions{}, errors.New("no request found") + return ws, nil, []*WorkflowExecutions{}, errors.New("no request found") } c := request.Caller if c == nil || c.URLS == nil || c.URLS[tools.BOOKING] == nil { - return nil, []*WorkflowExecutions{}, errors.New("no caller defined") + return ws, nil, []*WorkflowExecutions{}, errors.New("no caller defined") } methods := c.URLS[tools.BOOKING] if _, ok := methods[tools.GET]; !ok { - return nil, []*WorkflowExecutions{}, errors.New("no path found") + return ws, nil, []*WorkflowExecutions{}, errors.New("no path found") } ok, wf, executions, err := ws.CheckBooking(wfID, request) if !ok || err != nil { - return nil, []*WorkflowExecutions{}, errors.New("could not book the workflow : " + fmt.Sprintf("%v", err)) + return ws, nil, []*WorkflowExecutions{}, errors.New("could not book the workflow : " + fmt.Sprintf("%v", err)) } ws.Workflow = wf @@ -110,14 +110,14 @@ func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (* for _, exec := range executions { err := exec.PurgeDraft(request) if err != nil { - return nil, []*WorkflowExecutions{}, errors.New("purge draft" + fmt.Sprintf("%v", err)) + return ws, nil, []*WorkflowExecutions{}, errors.New("purge draft" + fmt.Sprintf("%v", err)) } exec.GenerateID() exec.StoreDraftDefault() // Should DELETE the previous execution2 utils.GenericStoreOne(exec, NewAccessor(request)) } - return wf, executions, nil + return ws, wf, executions, nil } /*