jobfilter

package
v0.1.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTimestamp

func ParseTimestamp(value string) (time.Time, error)

ParseTimestamp parses the timestamp formats accepted by time filters.

Types

type Attributes

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

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) Empty

func (filter Filter) Empty() bool

Empty reports whether no condition is set.

func (Filter) HasRunConditions

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) 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

func (filter Filter) MatchesDefinition(id string) bool

MatchesDefinition reports whether an ID satisfies changed/new conditions.

func (Filter) Selects

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) SelectsArray

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL