Documentation
¶
Overview ¶
Package workflow provides multi-step orchestration for tdtpcli. Each step in a workflow YAML runs a tdtpcli sub-command; steps may declare dependencies on other steps and specify error recovery policies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyVars ¶
ApplyVars replaces {{name}} placeholders with values from vars. Exported so callers (e.g. RunSteps) can substitute descriptions before printing.
func Run ¶
func Run(ctx context.Context, cfg *WorkflowConfig, vars map[string]string, opts RunOptions) error
Run executes the workflow using Kahn's topological-sort algorithm. Steps in the same "wave" (no ordering constraint between them) run in parallel. The next wave starts only when all steps of the current wave have finished.
Error propagation rules:
- on_error:stop — abort immediately; dependents never run.
- on_error:skip — mark step as skipped; direct and transitive dependents are also skipped (they print a one-line notice instead of running).
- on_error:retry(N) — retry up to N times with exponential back-off (2s→30s). If all retries are exhausted, the step is treated as on_error:stop.
Types ¶
type OnErrorPolicy ¶
type OnErrorPolicy struct {
Action string // "stop" | "skip" | "retry"
Retries int // only when Action == "retry"
}
OnErrorPolicy is the parsed form of StepConfig.OnError.
func ParseOnError ¶
func ParseOnError(s string) (OnErrorPolicy, error)
ParseOnError parses on_error into a policy.
type RunOptions ¶
type RunOptions struct {
// Quiet drops the echoed command from each step's start line and adds
// --quiet to the child's arguments, so the whole tree stays terse. The
// command reappears in the failure line, which is the moment it is worth
// having.
Quiet bool
// Stdout and Stderr receive workflow progress and child process output.
// Nil keeps the v1 behaviour of writing to the process streams.
Stdout io.Writer
Stderr io.Writer
}
RunOptions controls what the run prints and what it passes down.
type StepConfig ¶
type StepConfig struct {
ID string `yaml:"id"`
Command string `yaml:"command"`
DependsOn []string `yaml:"depends_on"`
// OnError controls what happens when this step fails:
// ""/"stop" — abort the workflow (default)
// "skip" — mark this step as skipped, allow dependents to decide
// "retry(N)" — retry up to N times with exponential back-off (2s→30s)
OnError string `yaml:"on_error"`
}
StepConfig describes one step in a workflow.
type WorkflowConfig ¶
type WorkflowConfig struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Steps []StepConfig `yaml:"steps"`
}
WorkflowConfig is the top-level structure for a --steps YAML file.
func LoadWorkflow ¶
func LoadWorkflow(path string) (*WorkflowConfig, error)
LoadWorkflow reads and validates a workflow YAML file.
func (*WorkflowConfig) Validate ¶
func (w *WorkflowConfig) Validate() error
Validate checks the workflow for structural correctness.