Documentation
¶
Overview ¶
Package blockio provides CUE-validated YAML import/export for scheduling blocks, plus first-run bootstrap of a static scheduler file into the block store (see Bootstrap in bootstrap.go).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bootstrap ¶
Bootstrap performs first-run import of a static scheduler YAML file into the block store.
Behavior:
- If the store already has one or more blocks, Bootstrap is a no-op and returns (0, nil): the store is the source of truth once it has been populated, and a static file must never silently re-seed or duplicate data on every restart.
- If the store is empty but path does not exist, Bootstrap is a no-op and returns (0, nil): there is nothing to import.
- If the store is empty and path exists, Bootstrap parses and validates the file (via ParseYAML) and creates one BlockRecord per block, with a generated UUID as the ID, the block's Name, and Enabled set to true. It returns the number of blocks imported.
- If the file exists but fails to parse or validate, Bootstrap returns an error and imports nothing: validation happens on the whole file before any block is written, so a bad file can never leave the store half-imported.
func ParseYAML ¶
ParseYAML strictly decodes YAML data into scheduling blocks and validates the result against the CUE schema via ValidateBlocks. Decoding is strict: unknown fields anywhere in the document are rejected rather than silently ignored.
ParseYAML also rejects blocks that share a name. This lives here, ahead of ValidateBlocks, rather than inside ValidateBlocks or left for the store to catch: CUE validates each block against #Block independently and has no notion of "list of blocks with unique names," so two same-named blocks in one file would otherwise sail through CUE validation cleanly. Catching it here -- before any block from this file is written anywhere -- protects every YAML-driven import path (Bootstrap today, a future import API endpoint tomorrow) uniformly, without requiring store-level transactions: a duplicate never gets far enough to hit store.ErrConflict partway through a batch of writes.
func RenderYAML ¶
RenderYAML renders blocks as YAML, wrapped in the scheduler.Config envelope used by scheduler files. Because it marshals a typed struct (scheduler.Config) rather than a map, field order is stable across calls: it always follows the struct's declared field order, not map iteration order.
func ValidateBlocks ¶
ValidateBlocks validates blocks against the scheduler CUE schema. It renders the blocks to YAML (via RenderYAML) and runs the result through cueconfig's scheduler validator, wrapping any resulting CUE error.
Types ¶
This section is empty.