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 ¶
- Variables
- type Attested
- type GitHub
- type Manager
- func (m *Manager) Current() *Release
- func (m *Manager) Enabled() bool
- func (m *Manager) Install(ctx context.Context) (*Release, error)
- func (m *Manager) Installed() bool
- func (m *Manager) Latest(ctx context.Context) (*Release, error)
- func (m *Manager) Previous() *Release
- func (m *Manager) Rollback() (*Release, error)
- func (m *Manager) Root() string
- func (m *Manager) UpdateAvailable(latest *Release) bool
- type Orderer
- type Release
- type Source
Constants ¶
This section is empty.
Variables ¶
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
NewAttested is a Source for webRepo's attested releases. token may be empty.
func (*Attested) Latest ¶ added in v0.1.7
Latest is the newest web-<sha> release whose attestation verifies; one that doesn't check out is skipped.
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 ¶
NewGitHub is a Source serving what pinRepo's main pins, from webRepo's releases, authenticating with token.
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 ¶
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 ¶
Current is the release being served; nil when it's an image bundle that doesn't say what it is.
func (*Manager) Install ¶
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 ¶
Installed reports whether the bundle served was installed (true) or came with the image (false).
func (*Manager) Latest ¶
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) Rollback ¶
Rollback switches back to the bundle the last Install replaced; the one served becomes the bundle to roll forward to.
func (*Manager) UpdateAvailable ¶
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.
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.