Documentation
¶
Overview ¶
Package resolve turns command-line selectors into the base directory, project, run, and job they name.
It owns the location rules shared by every command that reads existing state: run IDs found through the run registry, attempt IDs, the latest-run fallback, run names, and job IDs or names looked up in the queue and the latest runs. Command-specific selector orders, such as show's or wait's, stay with the command and build on these functions.
Index ¶
- Variables
- func AmbiguousError(what string, targets []Job) error
- func Attempt(attemptID, cliBaseDir, cliProjectName, cliRunID string) (string, string, string, string, error)
- func ExistingProjectNames(baseDir string) ([]string, error)
- func ExistingRun(cliBaseDir, cliProjectName, runID string) (string, string, error)
- func ExistingRunID(cliBaseDir, cliProjectName, runID string) (string, string, string, error)
- func IsRunID(value string) bool
- func JobIDsByName(commands []model.QueuedCommand, names []string) (map[string]bool, []string)
- func JobInQueue(queue model.Queue, selector string, byName bool) (string, bool)
- func ProjectBaseDir(scope Scope, projectName string) (string, bool, error)
- func ProjectExists(baseDir, name string) bool
- func ProjectNames(baseDir, cliProjectName string) ([]string, error)
- func RegisteredProjectBaseDirs(projectName, except string) []string
- func RegisteredRun(masterDir, runID string) (runregistry.Location, error)
- func RequireProject(baseDir, projectName string) error
- func RunID(paths state.ProjectPaths, requested string) (string, error)
- func SplitProjectOrRun(selectors []string) (string, []string, error)
- type Job
- func JobInRun(paths state.ProjectPaths, runID, selector string, byName bool) (Job, bool, error)
- func Jobs(scope Scope, cliProjectName, selector string, byName, includeQueue bool) ([]Job, error)
- func LatestJobIDs(scope Scope, cliProjectName string, jobIDs []string) (Job, error)
- func QueuedOrLatestJobIDs(scope Scope, cliProjectName string, jobIDs []string) (Job, error)
- func RunsOrJobs(scope Scope, cliProjectName, selector string) ([]Job, error)
- type JobControl
- type ProjectNotFoundError
- type Run
- type Scope
Constants ¶
This section is empty.
Variables ¶
var ErrNoSettledRuns = errors.New("no settled runs")
ErrNoSettledRuns reports that a project has no completed run to select as "latest".
Functions ¶
func AmbiguousError ¶
AmbiguousError reports that selector, described by what (such as "job name \"prep\""), matches several targets, and lists them so the caller can pick one with --project-name or --run-id, or --basedir when they are in more than one state directory.
func Attempt ¶
func Attempt(attemptID, cliBaseDir, cliProjectName, cliRunID string) (string, string, string, string, error)
Attempt resolves the base directory, project, run, and job of an "att_" attempt ID. A cliRunID that disagrees with the attempt's run is an error.
func ExistingProjectNames ¶
ExistingProjectNames lists only project directories present in baseDir. It intentionally does not consult ROTARI_PROJECT_NAME or choose the default project, which aggregate views use when finding project candidates.
func ExistingRun ¶
ExistingRun resolves the base directory and project for a command that reads existing state. A registered runID supplies both; explicit values that conflict with its registry entry are errors, and a registered run whose directory is gone is reported as stale. Otherwise the normal base directory and project resolution applies.
func ExistingRunID ¶
ExistingRunID is ExistingRun that also resolves runID to a saved run of the project: "latest" becomes the latest run, and any other ID must exist. An empty runID stays empty.
func IsRunID ¶
IsRunID reports whether value has the shape of a generated run ID, telling a bare run ID apart from a job ID or an "att_" attempt ID.
func JobIDsByName ¶
JobIDsByName returns every job ID selected by one or more names in a run's command snapshot. A command name selects every job produced by that command, while an array task name selects only that task.
func JobInQueue ¶
JobInQueue finds a job by ID, or by name when byName, in queue. A command's own ID or name wins, so an array job's ID or name returns the array's command ID; a task ID or name, such as "ID-2" or "NAME[2]", returns that task's ID.
func ProjectBaseDir ¶
ProjectBaseDir finds the state directory of scope that has projectName. It reports false when none has it, and fails when several have it.
func ProjectExists ¶
ProjectExists reports whether name is an existing project of baseDir, as positional selectors such as those of show and wait try first.
func ProjectNames ¶
ProjectNames lists the projects a search covers: the explicitly chosen project, which must exist, or every project in baseDir, sorted.
func RegisteredProjectBaseDirs ¶
RegisteredProjectBaseDirs returns, sorted, the local default state directory and those registered in the master directory, other than except, that have projectName. A registry that cannot be read gives none, since callers only add it to an error as a hint.
func RegisteredRun ¶
func RegisteredRun(masterDir, runID string) (runregistry.Location, error)
RegisteredRun returns the location of runID from the run registry under masterDir. Unlike ExistingRun it has no fallback: a run that is not registered there is an error, so callers that serve one master directory never reach state outside it.
func RequireProject ¶
RequireProject reports a project that does not exist, for commands that read or edit a project rather than create one.
func RunID ¶
func RunID(paths state.ProjectPaths, requested string) (string, error)
RunID resolves the run a history command reads. An explicit requested run must exist; empty selects meta.json's last run, then the newest run directory, while "latest" selects the newest settled run.
func SplitProjectOrRun ¶
SplitProjectOrRun classifies positional selectors that name either a project or a saved run ID. A selector with the generated run ID shape is a run ID; anything else is a project name. At most one project may be named.
Types ¶
type Job ¶
type Job struct {
Run
JobID string
// FromQueue reports a job found in the current queue rather than a run.
FromQueue bool
// contains filtered or unexported fields
}
Job names a job in a run, or in the project's queue when FromQueue is set.
func JobInRun ¶
JobInRun finds a job by ID or name in runID's command snapshot. A run without a snapshot has no jobs; other snapshot read errors are returned.
func Jobs ¶
Jobs finds a job by ID or name across the selected projects of scope. With includeQueue it applies defaultJobs to each project and keeps the best candidates of each state directory; otherwise it looks only in each project's latest run.
func LatestJobIDs ¶
LatestJobIDs finds the one latest run that contains every job ID. It fails when an ID is missing, ambiguous, or the IDs span different runs.
func QueuedOrLatestJobIDs ¶
QueuedOrLatestJobIDs finds where every job ID is, like LatestJobIDs, but prefers a project's non-empty queue to its latest run, as Jobs does with includeQueue.
func RunsOrJobs ¶
RunsOrJobs finds what selector names as a run name, a job ID, or a job name, for a selector that may be any of them: every run named selector, and the best job candidates by ID and by name of each state directory.
type JobControl ¶
JobControl is the target of a cancel, suspend, or resume selection: a project's active run, and the jobs in it, or every job when JobIDs is empty. RunID is the run the selection names, which the active run must be; it is empty when the selection names none.
func JobSelection ¶
func JobSelection(scope Scope, cliProjectName string, ids []string) (JobControl, error)
JobSelection resolves the target of a cancel/suspend/resume selection that may mix plain job IDs, "att_" attempt IDs, and at most one bare run ID. A bare run ID locates the target run through the run registry and is not itself a job selector, so it is removed from the job IDs. Without a run, an attempt, or a project, plain job IDs are looked for in the active run of every project of scope, and must all be in one.
type ProjectNotFoundError ¶
type ProjectNotFoundError struct {
// contains filtered or unexported fields
}
ProjectNotFoundError reports a missing project, with location hints. Selector callers can distinguish it from failures to read existing state.
func (*ProjectNotFoundError) Error ¶
func (err *ProjectNotFoundError) Error() string
type Run ¶
Run names a run's location.
func QueueWithJobs ¶
QueueWithJobs finds the project whose non-empty queue holds the commands selector names by job ID or name, for queue edits without a project. It reports false when selector names a group or no queue holds them, leaving project resolution to report it.
type Scope ¶
Scope is where a selector is looked for. Pinned, for --basedir or a command that runs or changes jobs, keeps the search in BaseDir, the command's state directory value. Otherwise BaseDir, from ROTARI_BASEDIR or a config file, is only searched first: when nothing matches there, the local default state directory and those registered in the master directory are searched alike, so a selector matching in more than one of them is ambiguous. ExplicitProject reports a project named on the command line, which keeps a selector in that project; a project from ROTARI_PROJECT_NAME or a config file is only searched first.