Documentation
¶
Overview ¶
Package builder builds catalog snapshots: it asks the upstream sources (Mojang, PaperMC and PurpurMC for server software; Modrinth and Hangar for plugins), applies the curation files, and publishes a signed snapshot in format v1.
Index ¶
Constants ¶
const ( Vanilla = "vanilla" Paper = "paper" Purpur = "purpur" Folia = "folia" Velocity = "velocity" )
Templates the catalog offers.
Variables ¶
var ErrDuplicate = errors.New("the snapshot lists an entry twice")
ErrDuplicate is returned when a snapshot lists a build, plugin or plugin version twice. Controllers key them, so they could not store it.
var ErrNotFound = errors.New("not found upstream")
ErrNotFound is returned for a 404 from upstream.
var ErrShrunk = errors.New("the new snapshot has more than 20 % fewer plugins than the published one")
ErrShrunk is returned when a build lost too many plugins compared with the published one, which usually means an upstream outage.
Functions ¶
func CompareVersions ¶
CompareVersions orders release numbers numerically ("1.21.10" after "1.21.9", "26.1" after "1.21.11"). Unparseable versions sort first.
func Publish ¶
func Publish(dir string, snap Snapshot, priv ed25519.PrivateKey, force bool, now time.Time) (format.Index, error)
Publish writes snap into dir as a signed snapshot: objects first, then index.json by atomic rename, so readers see the old snapshot or the new one, never a mix. The sequence always grows. Unless force is set, a snapshot that lost more than 20 % of the published plugins is refused. Objects no longer referenced and older than two days are pruned.
Types ¶
type Config ¶
type Config struct {
Client *http.Client
UserAgent string
// Interval spaces requests to one host (default 250 ms).
Interval time.Duration
MojangURL string
PaperURL string
PurpurURL string
ModrinthURL string
HangarURL string
// MinDownloads is the inclusion threshold for plugins (default 10,000);
// MaxPluginsPerSource caps each source (default 2,000);
// VersionsPerPlugin caps the versions kept (default 25).
MinDownloads int64
MaxPluginsPerSource int
VersionsPerPlugin int
Curation Curation
Logger *slog.Logger
// AllowHTTP permits plain HTTP upstreams; tests only.
AllowHTTP bool
}
Config tunes a build; empty URLs mean the public services.
type Curation ¶
type Curation struct {
Allow struct {
// Modrinth holds project IDs or slugs; Hangar "owner/slug".
Modrinth []string `json:"modrinth"`
Hangar []string `json:"hangar"`
} `json:"allow"`
Deny []format.Denial `json:"deny"`
}
Curation is the maintainers' input: plugins to include whatever their downloads, and the denylist.
func LoadCuration ¶
LoadCuration reads curation/allow.json and curation/deny.json.