queueops

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 16 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 queueops performs the queue and run-history edits that the CLI, the Web UI, and the supervisor share: add, change, remove, copy, and deleting runs.

Each operation resolves the project's paths, follows the idle-edit sequence of internal/project, and returns the one-line message every interface reports. Pure queue transformations belong to internal/queueedit and the selector rules to internal/model; this package loads and saves the files around them. It must not parse flags, prompt, or print.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNote

func AddNote(paths state.ProjectPaths, runID, attemptID, text string, now time.Time) (model.RunNote, error)

AddNote adds a note to the run runID of the project at paths, or, with an attemptID, to that job attempt of the run. The run may be active or finished: notes are appended and change none of its results.

func ValidateJobs

func ValidateJobs(queue model.Queue) error

ValidateJobs checks every queued command on its own and the job IDs they expand to: matrix groups, stage names, IDs as path elements, commands, environment, working directory, timeout, retry settings, arrays, and duplicate expanded IDs. Dependencies are checked separately by model.ValidateQueueDependencies, because add accepts dependencies on jobs added later.

Types

type Editor

type Editor struct {
	Store state.Store
	// Executors decides which executor names an added or changed job may
	// use.
	Executors executor.Registry
	// NewJobID returns a fresh job or matrix group ID.
	NewJobID func() string
	// UnregisterRun removes a deleted run from the run registry.
	UnregisterRun func(runID string) error
	// RegisterBaseDir records a basedir in which an applied add or copy
	// wrote a queue, so that discovery across basedirs finds the project.
	RegisterBaseDir func(baseDir string) error
	// Warn reports non-fatal warnings after a successful operation or preview.
	Warn func(string)
	// Guard previews the operations or applies them only at a given project
	// revision; see project.Guard. The zero Guard applies them.
	Guard project.Guard
}

Editor edits queues and run history on disk. Its fields are the process-wide settings the operations need.

func (Editor) Add

func (editor Editor) Add(baseDir, projectName string, commands []model.QueuedCommand, array *model.ArraySpec) (string, error)

Add appends commands to the project queue with new job IDs. A non-nil array makes every command an array job.

func (Editor) Change

func (editor Editor) Change(baseDir, projectName, requestedRunID string, selector model.CommandSelector, mutation Mutation) (string, error)

Change applies mutation to the selected jobs of the current queue, or of the batch restored from requestedRunID. It returns one line per changed job.

func (Editor) ChangeWithFilter

func (editor Editor) ChangeWithFilter(baseDir, projectName, requestedRunID string, selector model.CommandSelector, filter jobfilter.Filter, mutation Mutation) (string, error)

ChangeWithFilter applies mutation to the selected jobs, narrowing the selector with a filter before writing the queue.

func (Editor) Copy

func (editor Editor) Copy(baseDir, projectName, runID string, request queueedit.CopyRequest) (string, error)

Copy copies the jobs that request selects from runID into the queue. Attempt IDs in request.JobIDs select those attempts. The caller confirms an overwrite before setting request.Overwrite.

func (Editor) CopySnapshot

func (editor Editor) CopySnapshot(baseDir, sourceProject, runID, destinationProject string, destination model.Queue, request queueedit.CopyRequest) (model.Queue, int, error)

CopySnapshot builds the queue that CopyTo would produce from destination without writing it. The caller must hold the destination project's state lock when it needs the source and destination to describe one revision. Run startup uses this to build an immutable snapshot from a settled run while leaving queue.json for the next run untouched.

func (Editor) CopyTo

func (editor Editor) CopyTo(baseDir, sourceProject, runID, destinationProject string, request queueedit.CopyRequest) (string, error)

CopyTo is Copy from runID of sourceProject into the queue of destinationProject in the same basedir, which it creates when absent.

func (Editor) DeleteHistory

func (editor Editor) DeleteHistory(baseDir, projectName, runID string) (string, error)

DeleteHistory deletes one run, or every run of the project when runID is empty, and returns the message the CLI reports.

func (Editor) DeleteProject

func (editor Editor) DeleteProject(baseDir, projectName string) (string, error)

DeleteProject deletes an idle project: its directory, with the queue, run history, and project-scope configuration, and its runs' registry entries.

func (Editor) DeleteRun

func (editor Editor) DeleteRun(baseDir, projectName, runID string) error

DeleteRun deletes one run of an idle project.

func (Editor) Remove

func (editor Editor) Remove(baseDir, projectName, requestedRunID string, selector model.CommandSelector) (string, error)

Remove removes the selected jobs from the current queue, or from the batch restored from requestedRunID. A job that a remaining job depends on is not removed.

func (Editor) RemoveWithFilter

func (editor Editor) RemoveWithFilter(baseDir, projectName, requestedRunID string, selector model.CommandSelector, filter jobfilter.Filter) (string, error)

RemoveWithFilter removes the jobs selected by selector and further narrowed by filter from the current queue or from the batch restored from requestedRunID.

type Mutation

type Mutation struct {
	Executor              string
	ExecutorOptions       []string
	ClearExecutorOptions  bool
	Environment           []string
	ClearEnvironment      bool
	WorkingDirectory      string
	ClearWorkingDirectory bool
	SetJobName            string
	DependsOn             []string
	ClearDependsOn        bool
	// DependsOnFinished replaces DependsOnFinished when non-empty.
	DependsOnFinished      []string
	ClearDependsOnFinished bool
	// Artifacts replaces the declared artifact paths when non-empty.
	Artifacts      []string
	ClearArtifacts bool
	// Timeout replaces Timeout when non-empty.
	Timeout      string
	ClearTimeout bool
	// Retry replaces Retry when set; ClearRetry also clears the delay
	// settings.
	Retry      *int
	ClearRetry bool
	// RetryDelay, RetryBackoff, and RetryMaxDelay replace their fields when
	// set.
	RetryDelay    string
	RetryBackoff  float64
	RetryMaxDelay string
	// Status marks the job with a status in place of its recorded result's
	// when set; ClearStatus removes the mark. See model.MarkResult.
	Status      string
	ClearStatus bool
	Command     []string
}

Mutation is what change sets on each selected job. Empty values leave a field unchanged; a Clear field empties it.

Jump to

Keyboard shortcuts

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