presetlib

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, opts product.ValidateOptions,
) (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 under opts.

opts carries the operator's EXPR limits and this request's wall-clock backstop, because both preset routes that call this are reachable from an anonymous HTTP request when auth is off. The sha256 pinning bounds WHAT is validated -- the body is vouched for by the operator's index, not chosen by the caller -- but it does not bound how often, or for how long, this server is asked to validate it. See product.ValidateOptions.

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