Types
type Attributes struct {
Hosts []string
StartedAt time.Time
FinishedAt time.Time
Now time.Time
}
Attributes are the execution details used by host and time filters.
type Filter struct {
NotStages []string `json:"not_stages,omitempty"`
NotMatrices []string `json:"not_matrices,omitempty"`
Command string `json:"command,omitempty"`
ExitCodes []int `json:"exit_codes,omitempty"`
FailureKinds []string `json:"failure_kinds,omitempty"`
FailureCauses []string `json:"failure_causes,omitempty"`
Diagnoses []string `json:"diagnoses,omitempty"`
Changed bool `json:"changed,omitempty"`
New bool `json:"new,omitempty"`
ChangedIDs map[string]bool `json:"-"`
NewIDs map[string]bool `json:"-"`
Hosts []string `json:"hosts,omitempty"`
StartedAfter *time.Time `json:"started_after,omitempty"`
StartedBefore *time.Time `json:"started_before,omitempty"`
FinishedAfter *time.Time `json:"finished_after,omitempty"`
FinishedBefore *time.Time `json:"finished_before,omitempty"`
LongerThan time.Duration `json:"longer_than,omitempty"`
ShorterThan time.Duration `json:"shorter_than,omitempty"`
}
Filter narrows a job selection. A negated list excludes a job that matches
any of its values.
func (filter Filter) Empty() bool
Empty reports whether no condition is set.
func (filter Filter) HasRunConditions() bool
HasRunConditions reports whether the filter has a condition on a job's
result or execution, which only a run records.
func (filter Filter) MatchesAttributes(attributes Attributes) bool
MatchesAttributes reports whether execution attributes satisfy the filter.
Missing attributes never match a positive condition.
func (filter Filter) MatchesCommand(command model.QueuedCommand) bool
MatchesCommand reports whether command's definition passes the filter.
A command without a stage or matrix passes the negated stage and matrix
conditions.
func (filter Filter) MatchesDefinition(id string) bool
MatchesDefinition reports whether an ID satisfies changed/new conditions.
func (filter Filter) Selects(selection string, job Job) (bool, error)
Selects reports whether job is selected by a result selection and every
per-job condition of the filter. selection is a comma-separated list such as
"failed,unfinished"; "" and "all" select every result. Definition conditions
are checked separately with MatchesCommand, because they apply to a whole
command.
The conditions are checked in order: the result selection, the result
conditions, the changed/new IDs, then the host and time conditions, then the
diagnosis. The job's attributes and log are read only when every earlier
condition holds, so a job already excluded is never read. An error reading
them is returned, never taken as a non-match.
func (filter Filter) SelectsArray(selection string, tasks []Job) (bool, error)
SelectsArray reports whether an array job decided as a whole is selected:
its aggregate result, finished when every task is and failed when any task
is, matches selection, and some task satisfies every per-job condition.
Tasks are tried in order until one matches; an error reading a task tried
before then is returned.
type Job struct {
ID string
Result model.JobResult
Finished bool
Attributes Attributes
// LoadAttributes, when set, reads Attributes instead. It is called only
// for a filter with host or time conditions. An attribute that was never
// recorded is left zero; one that was recorded but cannot be read is an
// error.
LoadAttributes func() (Attributes, error)
// Diagnosis reports whether the job's diagnosis matches any selector. It
// is called only for a filter with diagnosis conditions; nil never
// matches. A log that cannot be read is an error, and a missing one
// does not match.
Diagnosis func(selectors []string) (bool, error)
}
Job is what a selection needs to know about one job or array task.
func (job Job) ExecutionAttributes() (Attributes, error)
ExecutionAttributes returns the job's Attributes, read through
LoadAttributes when it is set.