Documentation
¶
Overview ¶
Package presetlib is the client for a community preset library: it fetches a static JSON index (cached in memory) and, on install, fetches and verifies a single preset definition. The configured index URL is the trust boundary; the per-entry sha256 is an integrity + update-detection check, not authorship.
Index ¶
Constants ¶
const DefaultCacheTTL = 5 * time.Minute
DefaultCacheTTL is how long a fetched index is reused before re-fetching.
Variables ¶
var ErrFingerprintMismatch = errors.New("presetlib: definition fingerprint mismatch")
ErrFingerprintMismatch is returned when a downloaded definition's sha256 does not match the fingerprint the index vouched for.
var ErrNotConfigured = errors.New("presetlib: no preset library configured")
ErrNotConfigured is returned when no library URL is configured.
Functions ¶
This section is empty.
Types ¶
type IndexEntry ¶
type IndexEntry struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"`
Category string `json:"category"`
Version string `json:"version"`
Definition string `json:"definition"`
Sha256 string `json:"sha256"`
}
IndexEntry is one preset listed in the library index. Definition is a path resolved relative to the index URL.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service fetches and caches the library index and fetches preset definitions.
func New ¶
New returns a Service for the index at rawURL (empty ⇒ disabled), caching the index for ttl.
func (*Service) Configured ¶
Configured reports whether a library URL is set.
func (*Service) FetchDefinition ¶
FetchDefinition downloads the entry's definition (resolved relative to the index URL), verifies its sha256, and parses it into a store.Product.
func (*Service) FetchIndex ¶
FetchIndex returns the parsed index, served from cache within the TTL unless forceRefresh is set.