registry

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package registry is a generic, YAML-persisted store of named entries shared by the plugin and skill-pack installers. Both persist the same record shape (Entry) under a single top-level key (e.g. "plugins" or "packs"); the only difference is the file name and that key, so the storage logic lives here once and is parameterized per caller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name      string `yaml:"name"`
	SourceURL string `yaml:"source_url"`
	Ref       string `yaml:"ref"`
	Enabled   bool   `yaml:"enabled"`
}

Entry is one installed item's registry record. Plugins and skill packs share this shape.

type Registry

type Registry[E any] struct {
	Entries []E
	// contains filtered or unexported fields
}

Registry is a list of entries persisted to <baseDir>/<file> under a single top-level YAML key. It is generic over the entry type; nameOf extracts the unique name used by Find/Upsert/Remove.

func Load

func Load[E any](baseDir, file, key string, nameOf func(E) string) (*Registry[E], error)

Load reads <baseDir>/<file>, returning an empty registry if the file does not exist yet. The file is a single top-level mapping of key → entry list, so an unrelated key or a missing file both yield no entries.

func (*Registry[E]) Find

func (r *Registry[E]) Find(name string) *E

Find returns a pointer to the entry with the given name, or nil. Mutating the returned entry mutates the registry in place.

func (*Registry[E]) Remove

func (r *Registry[E]) Remove(name string) bool

Remove deletes an entry by name, reporting whether one was removed.

func (*Registry[E]) Save

func (r *Registry[E]) Save() error

Save writes the registry back to disk, creating baseDir if needed.

func (*Registry[E]) Upsert

func (r *Registry[E]) Upsert(e E)

Upsert replaces an existing entry by name, or appends a new one.

Jump to

Keyboard shortcuts

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