commands

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 5 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 commands lets a worker's operator say where a command a job runs really lives.

An OpenJD template names the program it runs ("nuke", "blender"). Nothing guarantees that name exists on a host: Nuke installs as Nuke17.1.exe, and a shell alias is invisible because the worker starts commands directly, with no shell. The operator's worker.commands table closes that gap. It maps a command name to the executable to run in its place, with optional leading arguments (for example Nuke's --nc flag for a non-commercial license).

The table is operator configuration, never job input, so a job cannot use it to reach anything it could not already name. The package is stdlib-only: it is imported by the config loader, the session manager and the executor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// Path is the executable to run: an absolute path, or a bare name the
	// worker's own PATH resolves when the process starts.
	Path string `yaml:"path"`
	// Args go before the arguments the job supplies. They are literal: no
	// format-string expansion.
	Args []string `yaml:"args"`
}

Command is what a command name resolves to.

type Problem

type Problem struct {
	// Key is the table key the problem is about.
	Key     string
	Message string
}

Problem is one reason a Table entry is unusable.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver applies a Table. The zero value and nil resolve nothing.

func NewResolver

func NewResolver(t Table) *Resolver

NewResolver returns a Resolver for t on this host. t is not copied; the caller must not change it afterwards.

func (*Resolver) Resolve

func (r *Resolver) Resolve(command string, args []string) (resolved string, resolvedArgs []string)

Resolve returns what to run for command and the arguments to run it with. A name with no entry is returned unchanged. A mapped name runs the entry's Path, with the entry's Args before args. The returned slice is always the caller's to keep: it never aliases args or the table.

type Table

type Table map[string]Command

Table maps a command name, as a job writes it, to what to run instead.

func (Table) Contains

func (t Table) Contains(name string) bool

Contains reports whether name has an entry, by this host's name rules: exact on POSIX, case-insensitive on Windows. It is the same question Resolve asks, so a caller deciding whether to add a default does not add one the table would already answer.

func (Table) Lookup

func (t Table) Lookup(name string) (Command, bool)

Lookup returns the entry for name by this host's name rules, as Contains decides.

func (Table) Validate

func (t Table) Validate() []Problem

Validate reports every unusable entry, ordered by key so the result is stable.

Jump to

Keyboard shortcuts

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