catalog

package
v1.20.0 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: 10 Imported by: 0

Documentation

Overview

Package catalog answers the Controller's software questions from the stored catalog snapshot (synced and verified by catalogsync): which versions of a template exist, and which build, download URL and published checksum a version resolves to. Jars download from the publisher's official URL. With Offline set, nothing is downloaded.

Index

Constants

View Source
const (
	Vanilla = "vanilla"
	Paper   = "paper"
	Purpur  = "purpur"
	Folia   = "folia"
	// Velocity is the network's proxy, not a Minecraft server: its
	// versions are its own.
	Velocity = "velocity"
)

Templates the catalog offers.

Variables

View Source
var (
	// ErrOffline is returned when downloads are switched off.
	ErrOffline = errors.New("software downloads are switched off (-offline)")
	// ErrNoSnapshot is returned before the first catalog sync succeeded.
	ErrNoSnapshot = errors.New("the catalog has not been synced yet")
	// ErrUnknownTemplate is returned for a template the catalog does not offer.
	ErrUnknownTemplate = errors.New("unknown software template")
	// ErrUnknownVersion is returned for a version the catalog does not offer.
	ErrUnknownVersion = errors.New("unknown or unsupported version")
	// ErrUnknownBuild is returned for a build the catalog does not offer.
	ErrUnknownBuild = errors.New("unknown build")
)

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 ServerTemplates added in v1.19.0

func ServerTemplates() []string

ServerTemplates returns the Minecraft server templates.

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.

func SupportedVersion added in v1.19.0

func SupportedVersion(template, version string) bool

SupportedVersion reports whether Shardkeep runs a template's version: Minecraft versions for server templates (see Supported), and Velocity's own releases from 3.0.

func Templates

func Templates() []string

Templates returns every supported template: the servers' and the proxy's.

Types

type Build

type Build struct {
	Template string
	Version  string
	// Build is empty for software without builds (Vanilla).
	Build string
	URL   string
	Hash  Hash
	// Size is zero when the publisher does not state it.
	Size        int64
	JavaVersion int
}

Build is one downloadable server jar.

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog reads the stored snapshot.

func New

func New(cfg Config) *Catalog

New returns a catalog.

func (*Catalog) Offline

func (c *Catalog) Offline() bool

Offline reports whether downloads are switched off.

func (*Catalog) Open

func (c *Catalog) Open(ctx context.Context, b Build) (io.ReadCloser, error)

Open starts downloading a build's jar from its publisher. The caller verifies it.

func (*Catalog) Resolve

func (c *Catalog) Resolve(ctx context.Context, template, version, build string) (Build, error)

Resolve returns the download for a template, version and build. An empty build means the newest stable one.

func (*Catalog) Versions

func (c *Catalog) Versions(ctx context.Context, template string) ([]string, error)

Versions lists a template's versions in the stored snapshot, newest first.

type Config

type Config struct {
	Offline bool
	Store   *store.Store
	// Download fetches jars (default: no overall timeout; the caller's
	// context bounds it).
	Download  *http.Client
	UserAgent string
}

Config wires the catalog.

type Hash

type Hash struct {
	// Algorithm is "sha1", "sha256" or "md5".
	Algorithm string
	Hex       string
}

Hash is a published checksum.

Jump to

Keyboard shortcuts

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