Documentation
¶
Overview ¶
Package webbundle finds the viewer for an agni binary that runs outside a checkout (agni WS16-003).
The server reads the viewer from a directory, so both sources end as one under the user cache. A release binary carries the bundle (package web, built with the embedweb tag) and writes it out once. A `go install` binary carries none, since the built JS is not in the Go module, and downloads the bundle its own release attached, checked against that release's checksums.txt. A build that is not a release (a checkout's `make agni`, `go install ...@main`) has no bundle to name, so it gets ErrNoBundle and keeps today's answer: `open` refuses and `serve` serves the API alone.
Index ¶
Constants ¶
const ChecksumsName = "checksums.txt"
ChecksumsName is the sha256 list a release attaches, one "<hex> <file>" line per asset.
const DefaultReleases = "https://github.com/panyam/agni/releases/download"
DefaultReleases is where a release's assets download from, as <base>/<tag>/<asset>.
Variables ¶
var ErrNoBundle = errors.New("this agni build carries no viewer")
ErrNoBundle means this binary has no viewer to offer, neither embedded nor a release to fetch from.
Functions ¶
Types ¶
type Source ¶
type Source struct {
// Embedded is the bundle the binary carries, nil when it carries none.
Embedded fs.FS
// Version is the binary's own version. A download is tried only for a release tag.
Version string
// Releases is the download base, DefaultReleases unless a test points it elsewhere.
Releases string
// CacheRoot holds one directory per bundle, under web/.
CacheRoot string
Client *http.Client
// Notes receives one line before a download, since a command that reaches the network should say so.
Notes io.Writer
}
Source says where a viewer may come from and where to keep it.
func (Source) Dir ¶
Dir returns a directory holding the viewer's templates/ and static/, and how it got there ("embedded" or "downloaded"). A directory written by an earlier call is reused. An error wraps ErrNoBundle when the binary has nothing to offer; any other error is a download or a write that failed, which a caller reports.