Documentation
¶
Overview ¶
Package queueedit applies edits to a project's queue as pure transformations.
It owns the rules for building a queue from an earlier run's command snapshot: which jobs a selection copies, which omitted prerequisites must have succeeded, how stage and matrix dependencies are kept or rewritten, and what origin each copied job records. Callers load and persist state, hold the locks, and validate attempt directories; this package must not touch the filesystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
func Copy(destination model.Queue, project string, source Run, request CopyRequest, newID func() string) (model.Queue, int, error)
Copy returns destination with the selected jobs of source added, and the number of jobs copied. project names the destination in error messages and newID generates IDs for colliding jobs and copied matrix groups.
Types ¶
type Attempt ¶
Attempt selects one attempt of a job in the source run. Callers check that the attempt belongs to the run and exists before copying.
type CopyRequest ¶
type CopyRequest struct {
// Selection is "all", "job-id", or a result selection such as "failed".
Selection string
// JobIDs are the jobs to copy, with Selection "job-id".
JobIDs []string
// Scope, when set, narrows Selection to one stage or matrix.
Scope model.CommandSelector
// Filter narrows Selection further.
Filter jobfilter.Filter
// PartialArray decides an array's tasks one by one for a result
// selection, and narrows the copied array to the selected tasks.
PartialArray bool
// Attempts are attempts to copy, with Selection "job-id". Selecting an
// attempt of an array task narrows the copied array to the selected tasks.
Attempts []Attempt
// Append keeps the destination queue's jobs; Overwrite replaces them.
// With neither, a non-empty destination queue is an error.
Append bool
Overwrite bool
}
CopyRequest selects the source jobs to copy.
type Run ¶
type Run struct {
ID string
Snapshot model.Queue
Results map[string]model.JobResult
CWD string
// Foreign reports that the run belongs to another project than the
// destination queue. Origins resolve only within a project's own runs,
// so jobs copied from it get none and are marked unfinished instead.
Foreign bool
// Timestamps returns a job's submitted and finished times in the run.
Timestamps func(jobID string) (submittedAt, finishedAt string)
// FilterJob returns what job filters need to know about a job or task of
// the run with the given result. Without it, host, time, and diagnosis
// filters match no job.
FilterJob func(jobID string, result model.JobResult, finished bool) jobfilter.Job
}
Run is the source run that jobs are copied from.