builder

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

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

View Source
const (
	Vanilla  = "vanilla"
	Paper    = "paper"
	Purpur   = "purpur"
	Folia    = "folia"
	Velocity = "velocity"
)

Templates the catalog offers.

Variables

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

View Source
var ErrNotFound = errors.New("not found upstream")

ErrNotFound is returned for a 404 from upstream.

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

func CompareVersions(a, b string) int

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.

func Supported

func Supported(v string) bool

Supported reports whether Shardkeep runs a Minecraft version: releases from 1.18 (the first needing Java 17), and every year-numbered release (26.1 onwards). Pre-releases, snapshots and release candidates are not.

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

func LoadCuration(dir string) (Curation, error)

LoadCuration reads curation/allow.json and curation/deny.json.

type Snapshot

type Snapshot struct {
	Software format.Software
	Plugins  format.Plugins
	Denylist format.Denylist
}

Snapshot is a built catalog, before it is published.

func Build

func Build(ctx context.Context, cfg Config, prev *Snapshot) (Snapshot, error)

Build fetches everything and returns the snapshot. prev, if set, is the last published snapshot: plugins unchanged since then keep their versions without further requests.

func Load

func Load(dir string, trusted []format.PublicKey) (format.Index, *Snapshot, error)

Load reads the snapshot published in dir. With trusted keys it is verified like a Controller would; without, it is the builder reading its own output.

Jump to

Keyboard shortcuts

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