Documentation
¶
Overview ¶
Package flow implements a declarative automation pipeline runner. Flows are defined in YAML files and consist of sequential steps that invoke cloop subcommands with optional conditions and failure policies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuiltinTemplates ¶
BuiltinTemplates returns all built-in flow templates keyed by name.
func ListFlows ¶
ListFlows returns all .yaml / .yml files found in the flows directory (.cloop/flows/ relative to workDir).
func MarshalYAML ¶
MarshalYAML serialises a Flow to a YAML byte slice with a header comment.
Types ¶
type Flow ¶
type Flow struct {
// Name is a human-readable title for the pipeline.
Name string `yaml:"name"`
// Description is an optional longer description of the pipeline's purpose.
Description string `yaml:"description,omitempty"`
// Steps is the ordered list of pipeline steps.
Steps []FlowStep `yaml:"steps"`
}
Flow is the top-level structure parsed from a flow YAML file.
func ExampleFlow ¶
func ExampleFlow() *Flow
ExampleFlow returns a sample Flow struct that can be serialised to YAML.
func Load ¶
Load reads and parses a Flow from the given YAML file path. The read is bounded by maxFlowYAMLBytes — a runaway file (e.g. a multi-GB blob in .cloop/flows/, or a user-supplied path pointing at the wrong artifact) is rejected with *boundedread.SizeError before any payload is loaded.
func ReleaseFlow ¶
func ReleaseFlow() *Flow
ReleaseFlow returns the built-in release pipeline template.
type FlowStep ¶
type FlowStep struct {
// Name is a human-readable label for the step.
Name string `yaml:"name"`
// Command is the cloop subcommand to invoke (e.g., "lint", "run", "report").
Command string `yaml:"command"`
// Args are extra arguments passed to the cloop subcommand.
Args []string `yaml:"args,omitempty"`
// If is a shell condition evaluated before executing the step.
// The step is skipped when the condition exits non-zero.
// Example: "test -f go.mod"
If string `yaml:"if,omitempty"`
// OnFailure controls behaviour when the step's Command fails.
// Valid values: "continue" (default), "abort", "retry".
OnFailure OnFailurePolicy `yaml:"on_failure,omitempty"`
// Env holds extra environment variables injected for this step only.
Env map[string]string `yaml:"env,omitempty"`
// MaxRetries is the number of additional attempts when OnFailure is "retry".
// Defaults to 2.
MaxRetries int `yaml:"max_retries,omitempty"`
}
FlowStep represents a single step in an automation pipeline.
type OnFailurePolicy ¶
type OnFailurePolicy string
OnFailurePolicy controls what happens when a step fails.
const ( OnFailureContinue OnFailurePolicy = "continue" OnFailureAbort OnFailurePolicy = "abort" OnFailureRetry OnFailurePolicy = "retry" )
type RunConfig ¶
type RunConfig struct {
// WorkDir is the directory from which cloop commands are executed.
WorkDir string
// CloopBin is the path to the cloop binary. Defaults to the current executable.
CloopBin string
// DryRun prints commands without executing them.
DryRun bool
// Stdout and Stderr for step output. Defaults to os.Stdout/Stderr.
Stdout *os.File
Stderr *os.File
}
RunConfig controls the behaviour of Run.