overlay

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 10 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 overlay is the domain layer for catalog overlays: user-owned sparse spec patches applied on top of pristine catalog TEMPLATE rows to produce the EFFECTIVE rows the snapshot serves.

Why this exists: catalog-managed resources are re-seeded from the upstream catalog, and a direct edit to such a row is clobbered by the next re-seed (or, worse, blocks it). An overlay stores ONLY the fields the user changed; the merge happens at catalog load time (app/catalog snapshot build / reconcile), never in storage — so re-seeding replaces templates and is completely overlay-unaware, while un-overridden fields keep tracking the upstream catalog. Factory reset = delete the overlay row.

Deliberately out of scope (v1): kinds other than "model"; diff-on-write against generic CRUD PUT (the overlay is an explicitly user-managed patch document); per-field replace-mode escalation on union fields; metadata/identity patches (a name-overriding overlay — a "clone" — is a designed future, not built); patching `enabled` (membership stays a sanctioned direct edit so the snapshot's enabled-filter semantics never depend on a merge).

Index

Constants

View Source
const KindModel = "model"

KindModel is the only overlayable kind in v1. The schema and store are kind-generic so new kinds are data, not migrations.

Variables

This section is empty.

Functions

func EffectiveModel

func EffectiveModel(template *model.Model, o *Overlay) (*model.Model, error)

EffectiveModel merges o onto the template model and validates the result. The returned model shares the template's Metadata (identity is never patchable); only Spec differs. An error means the merge produced an invalid effective row — callers QUARANTINE the overlay (serve the pristine template, log loudly) rather than failing the snapshot.

func MergeSpec

func MergeSpec(kind string, templateSpec, patch []byte) ([]byte, error)

MergeSpec applies patch onto templateSpec (both JSON objects) per the kind's strategy and returns the effective spec JSON.

func TargetKey

func TargetKey(kind, resourceID string) string

TargetKey builds the kind|resourceID composite key used by the snapshot index and the NOTIFY payload.

Types

type Overlay

type Overlay struct {
	Kind       string          `json:"kind"`
	ResourceID string          `json:"resourceId"`
	Patch      json.RawMessage `json:"patch"`
	UpdatedAt  time.Time       `json:"updatedAt,omitempty"`
}

Overlay is one user-owned sparse patch targeting a template row. Patch is a JSON object of SPEC fields only — top-level keys merge into the target's spec per the kind's Strategy (see merge.go). It is NOT a full resource: metadata is never patchable.

func (*Overlay) Key

func (o *Overlay) Key() string

Key returns the snapshot index key for this overlay's target.

func (*Overlay) Validate

func (o *Overlay) Validate() error

Validate enforces the overlay's intra-row rules. Post-merge validation (the effective row must pass the target kind's Validate) is the caller's job — it needs the template.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the Overlay data-access type.

func NewStore

func NewStore(q *gen.Queries) *Store

NewStore constructs a Store from an existing sqlc Queries handle.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, kind, resourceID string) error

Delete removes the overlay targeting (kind, resourceID). Idempotent.

func (*Store) Get

func (s *Store) Get(ctx context.Context, kind, resourceID string) (*Overlay, error)

Get returns the overlay targeting (kind, resourceID), or nil when none exists.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*Overlay, error)

List returns every overlay row.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, o *Overlay) error

Upsert writes o. The PG trigger emits the catalog NOTIFY.

Jump to

Keyboard shortcuts

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