Documentation
¶
Overview ¶
Package lifecycle plans and executes component operations across stack kinds.
Index ¶
- Variables
- func Execute(ctx context.Context, plan *Plan, opts *ExecutionOptions) *scheduler.AggregateResult
- func Label(n *dependency.Node) string
- func MustRegister(kind string, event Event, handler *Handler)
- func NodeID(kind, stack, name string) string
- type Event
- type ExecutionOptions
- type Filter
- type Handler
- type Notice
- type Plan
- type Registry
- type Selection
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry contains handlers registered by the component command packages.
Functions ¶
func Execute ¶
func Execute(ctx context.Context, plan *Plan, opts *ExecutionOptions) *scheduler.AggregateResult
Execute runs a prevalidated plan with the shared ready-queue scheduler.
func Label ¶
func Label(n *dependency.Node) string
Label returns a readable fully qualified component identity.
func MustRegister ¶
MustRegister registers a built-in handler during package initialization.
Types ¶
type Event ¶
type Event string
Event is one of the supported stack lifecycle events. A component type opts in to an event by registering its handler; other command names imply no support.
type ExecutionOptions ¶
type ExecutionOptions struct {
Executable string
Directory string
GlobalArgs []string
Environment []string
Streams process.Streams
Runner process.Runner
Concurrency int
KeepGoing bool
Grouped bool
ResourceGuards map[string]func(*dependency.Node) func()
// NodeEnvironment optionally returns KEY=VALUE entries applied on top of the
// child environment for one node. It runs on scheduler workers, so it must be
// safe for concurrent use.
NodeEnvironment func(node *dependency.Node) []string
// OnStart and OnComplete report live progress separately from child logs.
// Calls are serialized. Start occurs only after acquiring the resource guard.
OnStart func(*dependency.Node)
OnComplete func(*dependency.Node, error)
}
ExecutionOptions supplies dependencies and streams without mutating process state.
type Filter ¶
Filter selects components by their metadata. A component matches when its metadata.tags include any of Tags and its metadata.labels contain every pair in Labels. An empty filter matches every component.
type Handler ¶
type Handler struct {
Path []string
Args []schema.CommandArgument
Flags []schema.CommandFlag
Err error
// HookEvents are the actual per-component hook events fired by this command.
HookEvents []string
// ApprovalArgs opt into the component's own non-interactive approval behavior.
ApprovalArgs []string
// NewResourceGuard creates one shared lock domain for this invocation.
NewResourceGuard func(*schema.AtmosConfiguration) func(*dependency.Node) func()
// WorkerEnvironment supplies execution policy owned by this component type.
WorkerEnvironment func(int) []string
}
Handler binds a component kind's lifecycle event to an existing command. Invalid declarations retain their error so an unrelated kind does not fail selection.
func NativeHandler ¶
NativeHandler describes the standard component positional and stack flag.
type Notice ¶
type Notice struct {
Kind, Stack, Component, Reason string
}
Notice explains a component excluded from execution.
type Plan ¶
type Plan struct {
Graph *dependency.Graph
Commands map[string][]string
Notices []Notice
Handlers map[string]*Handler
// Deleted counts notices for selected definitions removed from configuration.
Deleted int
}
Plan is an immutable scheduling graph with resolved command arguments.
func BuildPlan ¶
func BuildPlan(stacks map[string]any, commands map[string]*Handler, selection *Selection, leftDelim string) (*Plan, error)
BuildPlan resolves selection, capability, and ordering before any operation runs.
Required prerequisites of a kind that cannot run the operation fail a deploy plan, while a destroy plan fails when components outside the selection still require something it would destroy. Other forward operations require handler support for prerequisites only when dependency expansion requests them. Locked components are never operated on.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry associates a component type and a fixed lifecycle event with an isolated-command handler. Custom configuration is merged into a per-invocation snapshot, so loading one project's commands cannot affect another project.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates an independent registry, useful for hosts and tests.
func (*Registry) Handlers ¶
Handlers returns an independent snapshot of types supporting the given event.
type Selection ¶
type Selection struct {
// Operation determines preflight and deletion notices; empty preserves deploy semantics.
Operation Event
Stack string
// Components selects exact names across kinds before expansion; empty selects every name.
Components []string
// A nil Affected selects all nodes; a non-nil empty slice selects none.
Affected []schema.Affected
// Zero disables expansion, -1 expands without a depth limit.
Dependencies int
Dependents int
Reverse bool
// Filter narrows the initial selection by component tags and labels.
Filter *Filter
}
Selection selects seeds before expanding dependencies in the original graph.