seed

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func DirVersion(dir string) string

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

func FetchCatalog(ctx context.Context, urlTemplate, version, destDir string) (string, error)

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

func IsLatestAlias(v string) bool

IsLatestAlias reports whether v selects channel-latest resolution instead of naming a concrete catalog release.

func ResolveLatest added in v0.9.9

func ResolveLatest(ctx context.Context, indexURL, channel string) (string, error)

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.

func Run

func Run(ctx context.Context, opts Options) (*Result, error)

Run executes the seed pipeline end-to-end.

Jump to

Keyboard shortcuts

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