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.
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
- func ArchiveChannel(archive []byte) (string, error)
- func BuildCatalog(archive []byte, generatedAt time.Time, version string) ([]byte, error)
- func BuildData(ctx context.Context, repo Repo, commit string) ([]byte, error)
- func DataAsset(tag string) string
- func SumFile(name string, data []byte) []byte
- type Config
- type Mirror
- type Repo
- type Server
- type Tag
Constants ¶
const CatalogAsset = "catalog.json.gz"
CatalogAsset is the SDK catalog file of every release.
Variables ¶
This section is empty.
Functions ¶
func ArchiveChannel ¶
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 ¶
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 ¶
BuildData builds the data tarball of commit. It never depends on compose, so a tree this binary can't load still yields its tarball.
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 ¶
Mirror is a bare clone of URL that follows its tags and main branch.
func (*Mirror) Fetch ¶
Fetch updates tags and main only. Never --mirror: on GitHub it also pulls refs/pull/*, unreviewed fork content.
type Repo ¶
type Repo struct {
Dir string
}
Repo runs the git binary against one repository directory, bare or not.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server mirrors the catalog repository and serves its releases.