-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontext.go
More file actions
74 lines (65 loc) · 1.93 KB
/
context.go
File metadata and controls
74 lines (65 loc) · 1.93 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
68
69
70
71
72
73
74
package probe
import "sync"
// ResponseTime provides response time information for expressions
type ResponseTime struct {
Duration string `expr:"duration"`
Sec float64 `expr:"sec"`
}
// ExitStatus represents the unified status across all actions
type ExitStatus int
const (
ExitStatusSuccess ExitStatus = 0 // Action succeeded
ExitStatusFailure ExitStatus = 1 // Action failed
)
// Int returns the ExitStatus as an int for comparison
func (e ExitStatus) Int() int {
return int(e)
}
// String returns the ExitStatus as a string
func (e ExitStatus) String() string {
switch e {
case ExitStatusSuccess:
return "success"
case ExitStatusFailure:
return "failure"
default:
return "unknown"
}
}
// StepContext provides context data for step expression evaluation
type StepContext struct {
Vars map[string]any `expr:"vars"`
Res map[string]any `expr:"res"`
Req map[string]any `expr:"req"`
RT ResponseTime `expr:"rt"`
Report string `expr:"report"`
Outputs map[string]any `expr:"outputs"`
Status int `expr:"status"`
RepeatIndex int `expr:"repeat_index"`
}
// JobContext provides context data for job execution
type JobContext struct {
Vars map[string]any `expr:"vars"`
Config
Failed bool
// Current job ID for this context
CurrentJobID string
// Repeat tracking
IsRepeating bool
RepeatCurrent int
RepeatTotal int
StepCounters map[int]StepRepeatCounter // step index -> counter
countersMu *sync.Mutex // protects StepCounters for concurrent access
// Print writer
Printer *Printer
// Result for managing job-level output
Result *Result
// Job scheduler for managing job dependencies and execution
JobScheduler *JobScheduler
// Shared outputs across all jobs (accessible via expressions as "outputs")
Outputs *Outputs `expr:"outputs"`
}
// SetFailed marks the job context as failed
func (j *JobContext) SetFailed() {
j.Failed = true
}