webbundle

package
v0.3.99 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 26 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 webbundle keeps the web client loomuxd serves current without rebuilding or redeploying its image (LOOM-118). What to serve is what loomux/server's main branch pins (deploy/web-ref and deploy/web-sha256, LOOM-58 and #179): a reviewed PR there is the only way to change it. A Manager reads the pin, installs that release — downloaded, checked against the pinned sha256, unpacked, then swapped in atomically — and can roll back to the bundle it replaced. The image's own bundle is the floor it never deletes, and a newly deployed image replaces any install.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDisabled: no Source is configured, so nothing can be installed.
	ErrDisabled = errors.New("webbundle: updates are not configured")
	// ErrUpToDate: the pinned release is already served.
	ErrUpToDate = errors.New("webbundle: already up to date")
	// ErrNoPrevious: there is nothing to roll back to.
	ErrNoPrevious = errors.New("webbundle: no previous bundle to roll back to")
)

Functions

This section is empty.

Types

type Attested added in v0.1.7

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

Attested is the Source that installs what loomux/web's CI built on its main branch, proven by a GitHub build-provenance attestation (LOOM-118 option b, user decision 2026-10-05). The release JSON says what a release is; only a verified attestation (verifyAttestation) says it's genuine: signed for the repository's ci.yml running on refs/heads/main, over the tarball's sha256, from the commit the release names. Which release to install is the newest that verifies and is ahead, on main, of the bundle served (Orderer): never a step back or sideways.

Everything it reads is public: the token is optional, for GitHub's rate limit. Sigstore's public-good trust root comes from its TUF repository, cached under cacheDir.

func NewAttested added in v0.1.7

func NewAttested(webRepo, token, cacheDir string) *Attested

NewAttested is a Source for webRepo's attested releases. token may be empty.

func (*Attested) Latest added in v0.1.7

func (a *Attested) Latest(ctx context.Context) (*Release, error)

Latest is the newest web-<sha> release whose attestation verifies; one that doesn't check out is skipped.

func (*Attested) Newer added in v0.1.7

func (a *Attested) Newer(ctx context.Context, base, candidate string) (bool, error)

Newer reports whether candidate is ahead of base on the repository's history (GitHub's compare: "ahead").

func (*Attested) Tarball added in v0.1.7

func (a *Attested) Tarball(ctx context.Context, rel *Release) (io.ReadCloser, error)

Tarball opens rel's tarball asset.

type GitHub

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

GitHub is the Source that serves what loomux/server's main branch pins.

The trust anchor is the pin, not the release: deploy/web-ref (a loomux/web commit) and deploy/web-sha256 (its tarball's digest) change only through a reviewed PR to loomux/server, the same pin the image build checks (#179). The release web-<short> named by the pin supplies the bytes, and they must hash to the pinned digest. Nothing about the release itself — who created it, its tag, its JSON, its date — can make anything else install, since anyone able to push to loomux/web can publish a release that looks genuine.

The token needs Contents: read on both repositories (the pin's and the releases'). It never leaves the API host.

func NewGitHub

func NewGitHub(pinRepo, webRepo, token string) *GitHub

NewGitHub is a Source serving what pinRepo's main pins, from webRepo's releases, authenticating with token.

func (*GitHub) Latest

func (g *GitHub) Latest(ctx context.Context) (*Release, error)

Latest is the release the pin names, with the pinned digest as its SHA256.

func (*GitHub) Tarball

func (g *GitHub) Tarball(ctx context.Context, rel *Release) (io.ReadCloser, error)

Tarball opens rel's tarball asset.

type Manager

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

Manager serves the newest of the image's bundle and an installed one, and installs and rolls back bundles. Safe for concurrent use; installs and rollbacks run one at a time.

func New

func New(bakedDir, dir string, source Source) (*Manager, error)

New opens the bundles in dir (created if missing) next to the image's bundle in bakedDir. source may be nil: the Manager then serves what it has but can't install. An installed bundle is served only while the image is the one it was installed over: deploying another image means starting from its bundle.

func (*Manager) Current

func (m *Manager) Current() *Release

Current is the release being served; nil when it's an image bundle that doesn't say what it is.

func (*Manager) Enabled

func (m *Manager) Enabled() bool

Enabled reports whether a Source is configured.

func (*Manager) Install

func (m *Manager) Install(ctx context.Context) (*Release, error)

Install fetches the pinned release and, unless it's already served, verifies and unpacks it and switches to it; the bundle it replaces becomes the one Rollback returns to. Anything that fails leaves the bundle served as it was.

func (*Manager) Installed

func (m *Manager) Installed() bool

Installed reports whether the bundle served was installed (true) or came with the image (false).

func (*Manager) Latest

func (m *Manager) Latest(ctx context.Context) (*Release, error)

Latest is the release the Source offers (pinned, or the newest attested one), cached for a minute along with whether it's an update.

func (*Manager) Previous

func (m *Manager) Previous() *Release

Previous is the release Rollback would return to, or nil.

func (*Manager) Rollback

func (m *Manager) Rollback() (*Release, error)

Rollback switches back to the bundle the last Install replaced; the one served becomes the bundle to roll forward to.

func (*Manager) Root

func (m *Manager) Root() string

Root is the directory to serve the web client from right now.

func (*Manager) UpdateAvailable

func (m *Manager) UpdateAvailable(latest *Release) bool

UpdateAvailable reports whether latest (the pinned release) isn't the bundle served. Pinning an older commit is a change too: the pin, not a timestamp, says what to serve.

type Orderer added in v0.1.7

type Orderer interface {
	// Newer reports whether candidate is ahead of base (base "" is the
	// unversioned image bundle: anything is).
	Newer(ctx context.Context, base, candidate string) (bool, error)
}

Orderer is implemented by a Source whose release isn't named by a reviewed pin but chosen from what CI published (Attested): an update is then only a release whose commit is ahead of the served one on main, never a step back or sideways.

type Release

type Release struct {
	Schema  int       `json:"schema"`
	Repo    string    `json:"repo"`
	Commit  string    `json:"commit"`
	Short   string    `json:"short"`
	Tag     string    `json:"tag"`
	Tarball string    `json:"tarball"`
	SHA256  string    `json:"sha256"`
	BuiltAt time.Time `json:"built_at"`
	Subject string    `json:"subject,omitempty"`
	// contains filtered or unexported fields
}

Release is a published web bundle: the web-release.json loomux/web's CI writes next to the tarball (loomux/web docs/release.md). Only Commit and SHA256 are ever trusted, and only once they match a reviewed pin; BuiltAt and Subject are for display.

func (*Release) String

func (r *Release) String() string

String is the release's tag, for logs and errors.

func (*Release) Validate

func (r *Release) Validate() error

Validate checks r is self-consistent: tag, short sha, commit and tarball name all agree, and the digest is well formed. It says nothing about whether r is genuine — that is the Source's job.

type Source

type Source interface {
	// Latest is the release to serve, already validated against its pin.
	Latest(ctx context.Context) (*Release, error)
	// Tarball opens rel's tarball (as returned by Latest).
	Tarball(ctx context.Context, rel *Release) (io.ReadCloser, error)
}

Source lists published web bundles and fetches their tarballs.

Jump to

Keyboard shortcuts

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