dbcatalogbuild

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package dbcatalogbuild builds, validates and signs the database version catalog (databases.v1.json) from upstream registries and endoflife.date. The publisher script and the control plane's direct mode share it.

Index

Constants

View Source
const (
	ChannelStable = "stable"
	ChannelLTS    = "lts"
	ChannelRC     = "rc"
	ChannelBeta   = "beta"
	ChannelEOL    = "eol"
)

Release channels of a version.

View Source
const DockerHubBase = "https://registry-1.docker.io"

DockerHubBase is the OCI endpoint that serves Docker Hub repositories.

View Source
const EOLBase = "https://endoflife.date/api"

EOLBase is the endoflife.date API root.

View Source
const SchemaVersion = 1

SchemaVersion is the only catalog schema this build reads or writes.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey() (priv, pub string, err error)

GenerateKey returns a base64 private key and public key pair.

func Sign

func Sign(privB64 string, data []byte) (string, error)

Sign returns the base64 ed25519 signature of data.

func ValidChannel

func ValidChannel(c string) bool

ValidChannel reports whether c is a known release channel.

func ValidateAgainst

func ValidateAgainst(next File, prev *File) error

ValidateAgainst enforces the publish gates: schema, no empty engine, and no engine shrinking by more than a third versus prev (nil prev skips it).

func Verify

func Verify(pubB64, sigB64 string, data []byte) error

Verify checks a base64 signature of data against a base64 public key.

Types

type Builder

type Builder struct {
	Tags   TagLister
	Cycles CycleSource
	Accept func(engine, version string) bool
	Now    func() time.Time
}

Builder assembles catalog engines. Accept, when set, drops versions the control plane would refuse (ValidateEngineVersion).

func (*Builder) Build

func (b *Builder) Build(ctx context.Context, specs []Spec) (File, error)

Build builds every spec. One failing engine fails the run: a partial catalog must never replace a complete one.

func (*Builder) BuildEngine

func (b *Builder) BuildEngine(ctx context.Context, s Spec) (Engine, error)

BuildEngine builds one engine from its spec.

type Cycle

type Cycle struct {
	Cycle             string          `json:"cycle"`
	ReleaseDate       string          `json:"releaseDate"`
	EOL               json.RawMessage `json:"eol"`
	Latest            string          `json:"latest"`
	LatestReleaseDate string          `json:"latestReleaseDate"`
	LTS               bool            `json:"lts"`
}

Cycle is one endoflife.date release cycle.

type CycleSource

type CycleSource interface {
	Cycles(ctx context.Context, slug string) ([]Cycle, error)
}

CycleSource returns an engine's release cycles from endoflife.date.

type EOLClient

type EOLClient struct {
	HTTP *http.Client
	Base string
}

EOLClient reads cycles from the endoflife.date JSON API.

func (EOLClient) Cycles

func (c EOLClient) Cycles(ctx context.Context, slug string) ([]Cycle, error)

Cycles fetches <base>/<slug>.json.

type Engine

type Engine struct {
	Source   Source    `json:"source"`
	Versions []Version `json:"versions"`
	Lines    []Line    `json:"lines"`
}

Engine is one engine's published versions and release lines.

type File

type File struct {
	Schema      int               `json:"schema"`
	GeneratedAt string            `json:"generated_at"`
	Engines     map[string]Engine `json:"engines"`
}

File is the published catalog document.

func Parse

func Parse(raw []byte) (File, error)

Parse decodes and schema-checks a catalog document.

func (File) Marshal

func (f File) Marshal() ([]byte, error)

Marshal renders the file deterministically, indented, with a trailing newline.

type Line

type Line struct {
	Line string `json:"line"`
	EOL  string `json:"eol,omitempty"`
	LTS  bool   `json:"lts,omitempty"`
}

Line is a release line with its end-of-life date.

type RateLimitedError

type RateLimitedError struct {
	Source     string
	RetryAfter time.Duration
}

RateLimitedError is an upstream 429 with its Retry-After.

func (*RateLimitedError) Error

func (e *RateLimitedError) Error() string

type RegistryTags

type RegistryTags struct {
	Client  *registrycatalog.Client
	BaseURL string
}

RegistryTags lists tags through the OCI distribution API.

func (RegistryTags) ListTags

func (r RegistryTags) ListTags(ctx context.Context, repository string) ([]string, error)

ListTags implements TagLister, mapping a registry 429 to RateLimitedError.

type Source

type Source struct {
	EOLURL          string `json:"eol_url,omitempty"`
	TagsURL         string `json:"tags_url,omitempty"`
	ReleaseNotesURL string `json:"release_notes_url,omitempty"`
}

Source links to where an engine's data came from.

type Spec

type Spec struct {
	ID              string
	Repo            string
	EOLSlug         string
	ReleaseNotesURL string
	StableRe        *regexp.Regexp
	PreRe           *regexp.Regexp
	Lines           []string
}

Spec describes where one engine's data comes from. Group 1 of StableRe and PreRe is the release line a tag belongs to.

func DefaultSpecs

func DefaultSpecs() []Spec

DefaultSpecs lists the engines the publisher covers. Engines whose images are not on Docker Hub (dragonfly, keydb) are left to the embedded catalog. Extending Lines is the one edit a new supported major needs.

func SpecFor

func SpecFor(id string) (Spec, bool)

SpecFor finds an engine's default spec.

func (Spec) Source

func (s Spec) Source() Source

Source returns the links published for the spec's engine.

type TagLister

type TagLister interface {
	ListTags(ctx context.Context, repository string) ([]string, error)
}

TagLister lists every tag of a registry repository.

type Version

type Version struct {
	Version     string `json:"version"`
	Tag         string `json:"tag"`
	Channel     string `json:"channel"`
	Released    string `json:"released,omitempty"`
	EOL         string `json:"eol,omitempty"`
	Recommended bool   `json:"recommended"`
}

Version is one selectable image tag with its lifecycle.

Jump to

Keyboard shortcuts

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