Documentation
¶
Overview ¶
Package seed orchestrates loading YAML config into Postgres for the app/ arch. The flow:
- Parse every YAML in the source dir (multi-doc supported).
- List every row from each entity store to learn existing name→id bindings.
- For YAML names that have no PG row yet, mint a fresh UUIDv7 and add it to the resolver map.
- Translate each DTO → domain object via manifest.ToXxx using the merged resolver, stamping Meta.ID from the same map.
- Upsert in dependency order: Provider, Host, RateLimit, HostKey, Model, Policy, RelayKey.
Diffing, dry-run, and identity (User) handling are deliberately omitted — this is the minimal "make the rows be there" path. Idempotent: re-running over the same YAML is a no-op for unchanged rows and an in-place update for changed ones.
Index ¶
Constants ¶
const DefaultCatalogURLTemplate = "https://github.com/wyolet/relay-catalog/archive/{version}.tar.gz"
DefaultCatalogURLTemplate is where versioned catalog trees are fetched from when RELAY_CATALOG_URL is unset. "{version}" is replaced with the requested ref; GitHub serves source archives for any tag/branch/sha.
Variables ¶
This section is empty.
Functions ¶
func FetchCatalog ¶ added in v0.5.0
FetchCatalog downloads the catalog source archive for version from urlTemplate ("{version}" substituted; empty = DefaultCatalogURLTemplate), extracts it under destDir, and returns the directory holding the catalog data tree. Only regular files and directories are extracted — symlinks and entries escaping destDir are rejected.
The returned root follows the source-archive convention: a top-level `data/` dir wins (directly under destDir, or inside a single wrapping directory the way GitHub archives unpack); otherwise destDir itself is assumed to be the data tree.
Types ¶
type Options ¶
type Options struct {
Pool *pgxpool.Pool
YAMLDir string
MasterKey []byte // for stored-mode HostKey rows; nil disables them
// ClearDirty re-seeds (overwrites) rows an operator has edited, resetting
// them to the catalog version and clearing their dirty flag. Default false:
// dirty rows are skipped so re-seeding never clobbers operator changes.
ClearDirty bool
}
Options configures a seed run.