seed

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 30 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. The one step of its own is DetachDropped: it marks the catalog rows a new catalog release no longer ships instead of deleting them.

Index

Constants

View Source
const DefaultCatalogIndexURL = "https://catalog.wyolet.com/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://catalog.wyolet.com/releases/{version}/relay-catalog-data-{version}.tar.gz"

DefaultCatalogURLTemplate is where versioned catalog trees are fetched from when RELAY_CATALOG_URL is unset. "{version}" is replaced with the requested release tag.

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 ("v1alpha3").

func CreateMissingSystemRateLimits added in v0.10.3

func CreateMissingSystemRateLimits(ctx context.Context, store systemRateLimitStore, defs []*ratelimit.RateLimit) ([]string, error)

CreateMissingSystemRateLimits writes each definition whose name has no row and returns the names it created. A row that exists keeps what it holds, so an operator's edit or disable survives every boot. One exception: a row of a built-in name the organization owns was moved there by a binary that did not ship that name, and goes back to system unless an operator edited it since (then it is logged and left alone), since the relay looks its limits up as a system row.

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 archive for version from urlTemplate ("{version}" substituted; empty = DefaultCatalogURLTemplate), checks it against the sha256sum file at the same URL plus ".sha256", extracts it under destDir, and returns the directory holding the catalog data tree. A missing, malformed or mismatching sum is an error and nothing is extracted. Only regular files and directories are extracted — symlinks and entries escaping destDir are rejected.

A top-level `data/` dir is the data root (directly under destDir, or inside a single wrapping directory); 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 IndexResult added in v0.20.1

type IndexResult struct {
	// Latest is the channel's newest release; empty when NotModified.
	Latest string
	// ETag is the index's validator, sent back as If-None-Match next time.
	ETag string
	// NotModified reports a 304: the index is unchanged since ETag.
	NotModified bool
}

IndexResult is one read of the channel index.

func FetchLatest added in v0.20.1

func FetchLatest(ctx context.Context, indexURL, channel, etag string) (IndexResult, error)

FetchLatest is ResolveLatest as a conditional GET: a non-empty etag is sent as If-None-Match, and a 304 answers NotModified with no Latest.

type Options

type Options struct {
	Pool    *pgxpool.Pool
	YAMLDir string
	// Secrets writes stored-mode HostKey values; nil disables them.
	Secrets *appsecret.Secrets

	// 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

	// DetachDropped marks the catalog rows the tree no longer declares with
	// CatalogDetachedAt, and clears the mark on clean rows it declares again.
	// Only the versioned catalog reseed sets it: there the tree is the whole
	// catalog release, so a row it omits is one the release dropped.
	DetachDropped 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
	Users           int
	Accounts        int
	Pools           int
	Budgets         int
	Skipped         int // dirty rows preserved (operator-edited; not re-seeded)
	Conflicts       int // rows left alone: changed during the run, or a name the organization or a tenant owns
	Detached        int // catalog rows the tree no longer declares, marked this run
	Reattached      int // detached rows the tree declares again, unmarked this run
}

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.

type SystemRateLimits added in v0.10.3

type SystemRateLimits struct {
	Rows []*ratelimit.RateLimit
	// FromDir names the definitions taken from the directory instead of the shipped ones.
	FromDir []string
	// Ignored lists the directory documents that are not a system rate limit the binary ships, as "Kind/name".
	Ignored []string
}

SystemRateLimits is the set of system rate limit definitions a boot seeds.

func LoadSystemRateLimits added in v0.10.3

func LoadSystemRateLimits(shipped []byte, dir string) (*SystemRateLimits, error)

LoadSystemRateLimits parses the definitions shipped in the binary, then replaces each one a YAML file under dir also defines. Only shipped names are taken from dir: it changes what a built-in row starts as, it does not add rows. A missing dir is not an error.

Jump to

Keyboard shortcuts

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