From ac893f1c91268403376acc40d05b7762bf6253ed Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Wed, 15 May 2019 09:41:56 +0200 Subject: [PATCH] runservice: trigger run event in change run phase action --- internal/services/runservice/action/action.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/services/runservice/action/action.go b/internal/services/runservice/action/action.go index 466de78..670eb95 100644 --- a/internal/services/runservice/action/action.go +++ b/internal/services/runservice/action/action.go @@ -71,12 +71,18 @@ func (h *ActionHandler) ChangeRunPhase(ctx context.Context, req *RunChangePhaseR return err } + var runEvent *types.RunEvent + switch req.Phase { case types.RunPhaseRunning: if r.Phase != types.RunPhaseQueued { return errors.Errorf("run %s is not queued but in %q phase", r.ID, r.Phase) } r.ChangePhase(types.RunPhaseRunning) + runEvent, err = common.NewRunEvent(ctx, h.e, r.ID, r.Phase, r.Result) + if err != nil { + return err + } case types.RunPhaseFinished: if r.Phase != types.RunPhaseRunning { return errors.Errorf("run %s is not running but in %q phase", r.ID, r.Phase) @@ -84,7 +90,7 @@ func (h *ActionHandler) ChangeRunPhase(ctx context.Context, req *RunChangePhaseR r.Stop = true } - _, err = store.AtomicPutRun(ctx, h.e, r, nil, cgt) + _, err = store.AtomicPutRun(ctx, h.e, r, runEvent, cgt) return err }