catalogserver

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 31 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.

Out of scope: unreleased commits and branches, pre-release tags, webhooks, and signing. 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

This section is empty.

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 DataAsset

func DataAsset(tag string) string

DataAsset is the relay seed 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()
}

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.

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