pipeline

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const FailureDetailFile = ".stagefreight/failure-detail.json"

FailureDetailFile is the well-known path (relative to rootDir) where the inner build writes FailureDetail for the outer crucible to pick up.

Variables

View Source
var ErrDryRunExit = errors.New("dry-run exit")

ErrDryRunExit is a sentinel returned by DryRunGate to signal a clean exit. Pipeline.Run recognizes this and returns nil after rendering a partial summary.

Functions

func CIContextKV

func CIContextKV() []output.KV

CIContextKV returns the generic CI context key-value pairs. Command-specific KVs (registries, platforms, etc.) are added via BannerPhase's extraKV callback.

func CollectTargetsByKind

func CollectTargetsByKind(cfg *config.Config, kind string) []config.TargetConfig

CollectTargetsByKind returns all targets matching the given kind.

func RenderExitReason

func RenderExitReason(w io.Writer, f *FailureDetail)

RenderExitReason renders the operator-facing Exit Reason box. Single-line when command + exit code + reason fit in ~80 chars, two-line otherwise. Exported so the outer crucible path can call it.

Types

type FailureDetail

type FailureDetail struct {
	Command  string // "docker push cr.pcfae.com/prplanit/stagefreight:dev-ff98a93"
	ExitCode int    // 1
	Reason   string // "HTTP 500 (registry)"
	Stderr   string // raw stderr for --verbose
}

FailureDetail captures operator-meaningful error context for the Exit Reason section.

func ReadFailureDetail

func ReadFailureDetail(rootDir string) *FailureDetail

ReadFailureDetail loads a FailureDetail written by a crucible child. Returns nil if the file doesn't exist or can't be parsed.

type Phase

type Phase struct {
	Name string
	Run  func(pc *PipelineContext) (*PhaseResult, error)
}

Phase is a named unit of pipeline work.

func BannerPhase

func BannerPhase(extraKV func(*PipelineContext) []output.KV) Phase

BannerPhase renders the StageFreight banner and CI context block. extraKV lets each command add engine-specific key-value pairs (registry counts, platforms, etc.).

func DryRunGate

func DryRunGate(renderPlan func(pc *PipelineContext)) Phase

DryRunGate checks pc.DryRun and, if true, calls renderPlan then returns ErrDryRunExit.

func LintPhase

func LintPhase() Phase

LintPhase runs the pre-build lint gate. Returns a phase that skips if pc.SkipLint is true.

func PublishManifestPhase

func PublishManifestPhase() Phase

PublishManifestPhase writes the accumulated publish manifest. No-op (records "skipped") when the manifest has no artifacts.

type PhaseResult

type PhaseResult struct {
	Name    string
	Status  string // "success", "failed", "skipped"
	Summary string // one-line detail
	Elapsed time.Duration
	Details map[string]string // optional structured metadata
	Failure *FailureDetail    // operator-facing error context; nil on success
}

PhaseResult is what each phase reports for the summary table.

type Pipeline

type Pipeline struct {
	Phases []Phase
	Hooks  []PostBuildHook
}

Pipeline orchestrates build phases and hooks.

func (*Pipeline) Run

func (p *Pipeline) Run(pc *PipelineContext) error

Run iterates phases in order. On phase error (and StopOnPhaseError): renders partial summary, returns error. On ErrDryRunExit: renders partial summary, returns nil (clean exit). Then runs hooks conditionally (nil Condition = always run; errors recorded, not fatal). Finally renders summary table from pc.Results.

type PipelineContext

type PipelineContext struct {
	Ctx           context.Context
	RootDir       string
	Config        *config.Config
	Writer        io.Writer
	Color         bool
	CI            bool
	Verbose       bool
	SkipLint      bool
	DryRun        bool
	Local         bool
	PipelineStart time.Time
	Manifest      artifact.PublishManifest // accumulated by execute phases
	BuildPlan     *build.BuildPlan         // set by build planning phases when applicable; nil for pipelines with no build plan
	Results       []PhaseResult            // accumulated by pipeline runner

	// Scratch is a state bag for command-specific data flowing between phases.
	// Keys are package-scoped conventions (e.g., "binary.steps", "docker.engine").
	// Cross-package pipeline state uses typed fields above, not Scratch.
	Scratch map[string]any
}

PipelineContext is the shared state bag threaded through all phases.

type PostBuildHook

type PostBuildHook struct {
	Name      string
	Condition func(pc *PipelineContext) bool
	Run       func(pc *PipelineContext) (*PhaseResult, error)
}

PostBuildHook is optional post-build work with a condition gate. nil Condition means "always run".

Jump to

Keyboard shortcuts

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