-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.go
More file actions
67 lines (61 loc) · 2.36 KB
/
Copy pathevent.go
File metadata and controls
67 lines (61 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package taskrun
import "time"
// EventKind identifies one observable execution event.
type EventKind string
const (
// EventRunStarted is emitted once a run has a validated root task.
EventRunStarted EventKind = "run_started"
// EventRunFinished is emitted once the final status is known.
EventRunFinished EventKind = "run_finished"
// EventTaskStarted is emitted before a task call evaluates its steps.
EventTaskStarted EventKind = "task_started"
// EventTaskSkipped is emitted when a call is skipped by platform or condition.
EventTaskSkipped EventKind = "task_skipped"
// EventTaskFinished is emitted after a task call completes or fails.
EventTaskFinished EventKind = "task_finished"
// EventStepStarted is emitted before a step action runs.
EventStepStarted EventKind = "step_started"
// EventStepSkipped is emitted when a step is skipped by platform or condition.
EventStepSkipped EventKind = "step_skipped"
// EventStepFinished is emitted after a step completes, fails or is ignored.
EventStepFinished EventKind = "step_finished"
)
// Event is a structured execution event for host logging and progress display.
// Events never carry captured output; use Result for that. A successful run
// reports the final status through EventRunFinished.
type Event struct {
Kind EventKind
Task string
CallID string
Step string
// ActionKind is "exec", "shell", "file", "task" or "host" for step events.
ActionKind string
// Depth is the task call depth, starting at 1 for the root task.
Depth int
Status Status
// Reason explains a skipped task or step.
Reason string
// Dir is the effective working directory of the run, task or step.
Dir string
// ExitCode is set for a started process.
ExitCode *int
// Err carries the classified failure when one occurred.
Err error
Time time.Time
}
// Observer receives execution events. Observers cannot change scheduling and do
// not return errors. Callbacks of one run arrive in order from the goroutine
// running that run; different runs may call an observer concurrently, so the
// host must synchronize and return quickly.
type Observer func(Event)
// emit delivers one event. Inspect and DryRun produce no events because no
// action runs.
func (s *runState) emit(event Event) {
if s.r.cfg.observer == nil || s.mode == modeInspect {
return
}
if event.Time.IsZero() {
event.Time = time.Now()
}
s.r.cfg.observer(event)
}