Functions
func LoadSettledRun(paths state.ProjectPaths, runID string, validate func(model.Queue) error) (workflow.SourceRun, error)
LoadSettledRun reads a settled run as a source for export, after checking
with validate that its command snapshot can run.
func Reconcile(store state.Store, baseDir string, manifest workflow.Manifest, queue model.Queue) (model.Queue, []workflow.RemovedJob, error)
Reconcile matches a queue compiled from manifest to the source runs it
was exported from; see workflow.Reconcile. A manifest without a source is
returned unchanged.
func RequireSettledRun(paths state.ProjectPaths, runID string) error
RequireSettledRun refuses an active or interrupted run of the project:
runID, or any when runID is empty. Their results are not final,
so a manifest of them would re-execute jobs that may yet succeed. See
project.EnsureRunSettled.
func SourceRun(runID, runDir string, queue model.Queue, summary model.RunSummary) workflow.SourceRun
SourceRun describes a loaded run as a workflow source.
Types
type Import struct {
Store state.Store
BaseDir string
Project string
Manifest workflow.Manifest
// Overwrite allows replacing a queue that has jobs.
Overwrite bool
// Guard previews the import or applies it only at a given revision.
Guard project.Guard
// NewJobID returns a fresh job ID for the compiled queue.
NewJobID func() string
// Validate checks that the compiled queue can run, such as that its
// executors are known.
Validate func(model.Queue) error
// Register, when set, records an imported project's basedir for
// discovery once the import is written.
Register func(baseDir string) error
}
Import is one import of a manifest into a project.
func (request Import) Apply() (Plan, error)
Apply compiles the manifest, reconciles it with its source runs, checks it,
and writes it as the project's queue under the guard. It returns the plan,
with the revision before a dry run or after a written import.
type Plan struct {
Version int `json:"version"`
Project string `json:"project"`
Jobs []PlanJob `json:"jobs"`
Removed []workflow.RemovedJob `json:"removed"`
// Revision is the project's revision: for a dry run the one to pass as
// project.Guard.IfRevision, and after an import the one it produced.
Revision string `json:"revision"`
}
Plan is what an import does to a project's queue: the jobs it queues and
their source results, the source jobs it drops, and the project revision.
func NewPlan(projectName string, queue model.Queue, removed []workflow.RemovedJob) Plan
NewPlan describes queue, compiled for projectName, as an import plan.
func (plan Plan) Summary() PlanSummary
Summary summarizes plan.
type PlanJob struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Status string `json:"status"`
Command []string `json:"command"`
Source *PlanSource `json:"source,omitempty"`
Tasks []PlanTask `json:"tasks,omitempty"`
}
PlanJob is one queued job of a Plan.
type PlanJobSummary struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Status string `json:"status"`
Tasks map[string]int `json:"tasks,omitempty"`
}
PlanJobSummary is one job of a PlanSummary.
type PlanSource struct {
RunID string `json:"run_id"`
JobID string `json:"job_id"`
AttemptID string `json:"attempt_id,omitempty"`
Status string `json:"status"`
}
PlanSource names the decoded source attempt so a reviewer can check which
earlier result a queued job refers to.
type PlanSummary struct {
Project string `json:"project"`
Counts map[string]int `json:"counts"`
Jobs []PlanJobSummary `json:"jobs"`
Removed []workflow.RemovedJob `json:"removed"`
Revision string `json:"revision"`
}
PlanSummary is a Plan without commands and source attempts: each job's
status, an array's tasks counted by status, and the statuses counted over
the plan, where an array with task statuses counts each task instead of
itself.
type PlanTask struct {
ID string `json:"id"`
Status string `json:"status"`
Source *PlanSource `json:"source,omitempty"`
}
PlanTask reports the status of one array task that has source provenance.
type Sources struct {
Paths state.ProjectPaths
Store state.Store
}
Sources reads a project's runs and attempts as workflow sources.
func (sources Sources) Attempt(runID, jobID, attemptID string, command []string) (model.JobResult, bool, error)
Attempt reads one attempt's result, or reports false while it has none.
func (sources Sources) AttemptTimestamps(runID, jobID, attemptID string) (string, string)
AttemptTimestamps returns when an attempt was submitted and finished.
func (sources Sources) Run(runID string) (workflow.SourceRun, error)
Run reads runID as a workflow source run.