presetlib

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 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

View Source
const DefaultCacheTTL = 5 * time.Minute

DefaultCacheTTL is how long a fetched index is reused before re-fetching.

Variables

View Source
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.

View Source
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

func New(rawURL string, ttl time.Duration) *Service

New returns a Service for the index at rawURL (empty ⇒ disabled), caching the index for ttl.

func (*Service) Configured

func (s *Service) Configured() bool

Configured reports whether a library URL is set.

func (*Service) FetchDefinition

func (s *Service) FetchDefinition(ctx context.Context, entry IndexEntry) (store.Product, error)

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

func (s *Service) FetchIndex(ctx context.Context, forceRefresh bool) ([]IndexEntry, error)

FetchIndex returns the parsed index, served from cache within the TTL unless forceRefresh is set.

Jump to

Keyboard shortcuts

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