Documentation
¶
Overview ¶
Package seed loads a directory of manifest YAMLs into Postgres at boot.
It is app/apply driven from a directory: the same parse → mint → translate → diff → upsert path the control plane's POST /apply runs, with no authorizer (boot has no actor) and no prune (a catalog tree is additive). ClearDirty maps to apply's Force. Everything else — bucket order, id minting, the dirty-row skip, the change vocabulary — lives in app/apply.
Index ¶
- Constants
- func Channel() string
- func DirVersion(dir string) string
- func FetchCatalog(ctx context.Context, urlTemplate, version, destDir string) (string, error)
- func IsLatestAlias(v string) bool
- func ResolveLatest(ctx context.Context, indexURL, channel string) (string, error)
- type Options
- type Result
Constants ¶
const DefaultCatalogIndexURL = "https://raw.githubusercontent.com/wyolet/relay-catalog/main/index.yaml"
DefaultCatalogIndexURL is where the channel index is fetched from when RELAY_CATALOG_INDEX_URL is unset. The index maps schema channels to the newest catalog release published for them, so a relay only ever resolves "latest" within the apiVersion it can parse.
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 Channel ¶ added in v0.9.9
func Channel() string
Channel is the schema channel key this binary resolves "latest" against: the version segment of the manifest apiVersion ("v1alpha2").
func DirVersion ¶ added in v0.9.9
DirVersion returns the release stamp of a local catalog tree (the .version file next to the data), or "" when the tree is unstamped.
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.
func IsLatestAlias ¶ added in v0.9.9
IsLatestAlias reports whether v selects channel-latest resolution instead of naming a concrete catalog release.
func ResolveLatest ¶ added in v0.9.9
ResolveLatest fetches the channel index (indexURL, empty = DefaultCatalogIndexURL) and returns the newest catalog release for channel. A channel absent from the index is an error — it means no catalog release exists for this binary's schema version.
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
// CatalogKindsOnly refuses the non-catalog kinds. The boot paths set it: a
// catalog tree is fetched by tag from a public repository and must not be
// able to mint a Key, a HostKey, a ServiceAccount or a RoleBinding on the
// way in. Those kinds reach Postgres through `relay seed --apply`,
// `relay apply` or the control API, all of which have an actor to authorize.
CatalogKindsOnly bool
}
Options configures a seed run.
type Result ¶
type Result struct {
Teams int
Projects int
Providers int
Hosts int
RateLimits int
HostKeys int
Models int
Pricings int
HostBindings int
Policies int
ServiceAccounts int
Groups int
Roles int
RoleBindings int
PolicyBindings int
Keys int
Overlays int
Skipped int // dirty rows preserved (operator-edited; not re-seeded)
}
Result summarises a seed run. Per-kind counts are the rows the run reconciled — created, updated, or already matching the manifest.