catalogserver

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 42 Imported by: 1 module, 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 catalogserver serves relay-catalog releases over plain HTTP from a git mirror of the catalog repository.

Each release tag's two files (the data tarball and catalog.json.gz) are rebuilt from the tagged tree and served only when their sha256 matches the sum published with the tag's release; otherwise the published file itself is fetched, checked against its sum, and served. The channel index is derived from the tags, never copied, so it can't name a tag whose files aren't published and verified. The same Build steps produce the files the release publishes, so CI and the server share one builder. A release's icons are served one by one out of its verified data tarball.

A tag whose tree has an mcp/ directory also has an MCP template tarball, verified the same way and indexed in a separate /mcp/index.yaml under the channel of the mcp/ documents. Its documents are never parsed beyond apiVersion, and it never affects /index.yaml or the relay files.

Relays may register a receiver URL per channel; when a channel's latest tag moves, each receiver gets a nudge to re-read the index. Receivers are held in memory per replica and expire unless renewed. A repository push hook only asks for an early sync.

Out of scope: unreleased commits and branches, pre-release tags, signing, and any shared state between replicas. The server holds no credentials and no state beyond the mirror directory and memory.

Index

Constants

View Source
const CatalogAsset = "catalog.json.gz"

CatalogAsset is the SDK catalog file of every release.

Variables

View Source
var ErrNoDocuments = errors.New("no documents")

ErrNoDocuments means a tarball's tree holds no YAML document, so it has no channel.

View Source
var ErrNoMCPTree = errors.New("no mcp tree")

ErrNoMCPTree means a commit has no mcp/ directory, so its release has no MCP template tarball.

Functions

func ArchiveChannel

func ArchiveChannel(archive []byte) (string, error)

ArchiveChannel is the schema channel of a data tarball: the apiVersion suffix every document in it shares. It reads only apiVersion, so a schema this binary can't load still gets its channel.

func BuildCatalog

func BuildCatalog(archive []byte, generatedAt time.Time, version string) ([]byte, error)

BuildCatalog composes catalog.json.gz from a data tarball, so the catalog describes exactly the published tree. generatedAt is the tagged commit's time and the gzip header carries no name or mtime, which makes the bytes a function of the tree and this builder only.

func BuildData

func BuildData(ctx context.Context, repo Repo, commit string) ([]byte, error)

BuildData builds the data tarball of commit. It never depends on compose, so a tree this binary can't load still yields its tarball.

func BuildMCP added in v0.21.0

func BuildMCP(ctx context.Context, repo Repo, commit string) ([]byte, error)

BuildMCP builds the MCP template tarball of commit, or returns ErrNoMCPTree. Its documents are never parsed here: their schema belongs to the gateway that seeds them.

func DataAsset

func DataAsset(tag string) string

DataAsset is the relay seed tree file of the release tagged tag.

func MCPArchiveChannel added in v0.21.0

func MCPArchiveChannel(archive []byte) (string, error)

MCPArchiveChannel is the channel of an MCP template tarball, read the same way from its mcp/ tree. It is independent of the data tree's channel.

func MCPAsset added in v0.21.0

func MCPAsset(tag string) string

MCPAsset is the MCP template tree file of the release tagged tag.

func SumFile

func SumFile(name string, data []byte) []byte

SumFile is data's checksum line in sha256sum format.

Types

type Config

type Config struct {
	RepoURL      string
	ReleasesURL  string // files of tag live at <ReleasesURL>/<tag>/<name>
	MirrorDir    string
	SyncInterval time.Duration
	CacheBytes   int64
	HTTPClient   *http.Client // nil: a client with a one-minute timeout
	Logger       *slog.Logger // nil: slog.Default()

	// DisableWebhooks turns off receiver registration, release nudges and
	// the repository push hook.
	DisableWebhooks bool
	// AllowLoopbackWebhooks admits http:// receivers on loopback addresses.
	// For local development only; every other refused range stays refused.
	AllowLoopbackWebhooks bool
	// TrustedProxies are the peers whose X-Forwarded-For names the client
	// a registration is rate-limited by.
	TrustedProxies []*net.IPNet
	Version        string // sent in the User-Agent to receivers
}

Config configures a Server.

type Mirror

type Mirror struct {
	Repo
	URL string
}

Mirror is a bare clone of URL that follows its tags and main branch.

func (*Mirror) Fetch

func (m *Mirror) Fetch(ctx context.Context) error

Fetch updates tags and main only. Never --mirror: on GitHub it also pulls refs/pull/*, unreviewed fork content.

func (*Mirror) Init

func (m *Mirror) Init(ctx context.Context) error

Init creates the bare repository unless one already exists.

func (*Mirror) Tags

func (m *Mirror) Tags(ctx context.Context) ([]Tag, error)

Tags lists the mirror's tags that peel to a commit.

type Repo

type Repo struct {
	Dir string
}

Repo runs the git binary against one repository directory, bare or not.

func (Repo) Archive

func (r Repo) Archive(ctx context.Context, commit string) ([]byte, error)

Archive is the data tarball of commit: the data/ tree without data/drafts, gzipped by git's built-in writer, which a Go gzip can't reproduce.

func (Repo) Commit

func (r Repo) Commit(ctx context.Context, ref string) (string, time.Time, error)

Commit resolves ref to its commit and the commit's committer time, read from %cI so the original offset is kept.

func (Repo) MCPArchive added in v0.21.0

func (r Repo) MCPArchive(ctx context.Context, commit string) ([]byte, error)

MCPArchive is Archive for the mcp/ tree without mcp/drafts, or ErrNoMCPTree. The tree is checked first because git archive fails on a pathspec that matches nothing.

type Server

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

Server mirrors the catalog repository and serves its releases.

func New

func New(cfg Config) (*Server, error)

New validates cfg and returns a Server; Run starts it.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler serves the catalog release API. Nothing here compresses a response: clients check the sha256 of the stored bytes.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run initialises the mirror and syncs it every SyncInterval, and whenever an early sync is asked for, until ctx ends.

type Tag

type Tag struct {
	Name      string
	Commit    string
	Committed time.Time
}

Tag is a tag peeled to its commit.

Jump to

Keyboard shortcuts

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