product

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package product is the catalog layer over OpenJD templates: it parses product definition files, holds the embedded built-ins, validates inline templates, and overlays read-only built-ins on the store via Catalog.

Index

Constants

This section is empty.

Variables

View Source
var ErrReadOnly = errors.New("product: read-only")

ErrReadOnly is returned when a mutation targets a read-only product (built-in or installed preset).

Functions

func Builtins

func Builtins() []store.Product

Builtins returns the embedded built-in products, sorted by name. The returned slice is a copy; callers may not mutate the shared definitions.

func ParseDefinition

func ParseDefinition(data []byte) (store.Product, error)

ParseDefinition parses a YAML product definition file (metadata + inline template) into a store.Product. Source is left empty for the caller to set. The inline template is re-serialized to YAML and validated; a malformed template is an error.

func ValidateTemplate

func ValidateTemplate(rawTemplate string, format store.TemplateFormat, enforceLimits bool) error

ValidateTemplate parses rawTemplate as OpenJD in the given format and runs the standard validation. It returns nil when the template is valid, or an error carrying the OpenJD ValidationErrors when not.

Types

type Catalog

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

Catalog overlays the embedded built-ins on a ProductStore and enforces the read-only / name-shadowing rules. It is the only component aware of built-ins.

func NewCatalog

func NewCatalog(st store.ProductStore) *Catalog

NewCatalog returns a Catalog backed by st.

func (*Catalog) Create

func (c *Catalog) Create(ctx context.Context, p store.Product) (store.Product, error)

Create stores a new custom/installed product. It rejects names that shadow a built-in. An empty Source defaults to SourceCustom; an empty ID is assigned.

func (*Catalog) Delete

func (c *Catalog) Delete(ctx context.Context, name string) error

Delete removes a stored product. Built-ins are read-only.

func (*Catalog) GetByName

func (c *Catalog) GetByName(ctx context.Context, name string) (store.Product, error)

GetByName returns a built-in (preferred) or stored product, or ErrNotFound.

func (*Catalog) Install

func (c *Catalog) Install(ctx context.Context, def store.Product, ref, fingerprint string) (store.Product, bool, error)

Install stores a preset fetched from the library as an installed product. It create-or-overwrites by name: a new name is created; an existing installed product of the same name is overwritten (the update path); a name shadowing a built-in or colliding with a custom product returns store.ErrConflict. The returned bool is true when a new product was created, false on overwrite.

func (*Catalog) List

func (c *Catalog) List(ctx context.Context) ([]store.Product, error)

List returns built-ins merged with stored products, ordered by name.

func (*Catalog) Update

func (c *Catalog) Update(ctx context.Context, p store.Product) (store.Product, error)

Update replaces a stored product. Built-ins and installed presets are read-only (edit an installed preset by duplicating it to a custom product).

Jump to

Keyboard shortcuts

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