Documentation
¶
Overview ¶
Package jobfilter holds the conditions that --filter-* options add to a job selection. A filter only narrows: a job is selected when the result filter and the scope select it and every condition set here holds. The package reads no files; callers supply what a condition needs to know about each job.
Index ¶
- func ParseTimestamp(value string) (time.Time, error)
- type Attributes
- type Filter
- func (filter Filter) Empty() bool
- func (filter Filter) HasRunConditions() bool
- func (filter Filter) MatchesAttributes(attributes Attributes) bool
- func (filter Filter) MatchesCommand(command model.QueuedCommand) bool
- func (filter Filter) MatchesDefinition(id string) bool
- func (filter Filter) Selects(selection string, job Job) (bool, error)
- func (filter Filter) SelectsArray(selection string, tasks []Job) (bool, error)
- type Job
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attributes ¶
Attributes are the execution details used by host and time filters.
type Filter ¶
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) HasRunConditions ¶
HasRunConditions reports whether the filter has a condition on a job's result or execution, which only a run records.
func (Filter) MatchesAttributes ¶
func (filter Filter) MatchesAttributes(attributes Attributes) bool
MatchesAttributes reports whether execution attributes satisfy the filter. Missing attributes never match a positive condition.
func (Filter) MatchesCommand ¶
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) MatchesDefinition ¶
MatchesDefinition reports whether an ID satisfies changed/new conditions.
func (Filter) Selects ¶
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) SelectsArray ¶
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 ¶
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) ExecutionAttributes ¶
func (job Job) ExecutionAttributes() (Attributes, error)
ExecutionAttributes returns the job's Attributes, read through LoadAttributes when it is set.