seed

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package seed orchestrates loading YAML config into Postgres for the app/ arch. The flow:

  1. Parse every YAML in the source dir (multi-doc supported).
  2. List every row from each entity store to learn existing name→id bindings.
  3. For YAML names that have no PG row yet, mint a fresh UUIDv7 and add it to the resolver map.
  4. Translate each DTO → domain object via manifest.ToXxx using the merged resolver, stamping Meta.ID from the same map.
  5. 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

type Result

type Result struct {
	Providers    int
	Hosts        int
	RateLimits   int
	HostKeys     int
	Models       int
	Pricings     int
	HostBindings int
	Policies     int
	RelayKeys    int
	Skipped      int // dirty rows preserved (operator-edited; not re-seeded)
}

Result summarises a seed run.

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