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 ¶
- Variables
- func Builtins() []store.Product
- func ParseDefinition(data []byte) (store.Product, error)
- func ValidateTemplate(rawTemplate string, format store.TemplateFormat, enforceLimits bool) error
- type Catalog
- func (c *Catalog) Create(ctx context.Context, p store.Product) (store.Product, error)
- func (c *Catalog) Delete(ctx context.Context, name string) error
- func (c *Catalog) GetByName(ctx context.Context, name string) (store.Product, error)
- func (c *Catalog) Install(ctx context.Context, def store.Product, ref, fingerprint string) (store.Product, bool, error)
- func (c *Catalog) List(ctx context.Context) ([]store.Product, error)
- func (c *Catalog) Update(ctx context.Context, p store.Product) (store.Product, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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) GetByName ¶
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.