Documentation
¶
Overview ¶
Package luarocks indexes root-level rockspecs and rocks and derives the LuaRocks manifest consumed by the native client. A rockspec or rock is stored at the repository root under its flat file name, <name>-<version>-<revision>.rockspec or <name>-<version>-<revision>.<arch>.rock, and its rockspec, read from the stored bytes (from inside the ZIP for a rock), must name the package and version the file name does. The package index holds a version per <version>-<revision>, and the work queue writes the manifest files the client reads, manifest and manifest-5.1 to manifest-5.5, from the stored files.
Role ¶
artifacts module, ecosystem layer: the LuaRocks rockspec and rock index rules of the LuaRocks slice. Its Handler plugs into the item service through the format hooks (decision 0032), so every write in a LuaRocks repository reaches it whichever API carried it; the slice's http package (artifacts/ecosystem/luarocks/http) serves the native LuaRocks protocol over what it keeps.
Inputs ¶
- Driving: the format registry (artifacts/ecosystem), which hands the item service's hooks for luarocks repositories to Handler; the work queue (decision 0033), which runs the manifest work (Work, KindManifest) and every format's reindex through it; and the protocol, which parses flat file names (Parse), checks an upstream rockspec or rock before a remote caches it (ValidateContent), and maps an uploaded rockspec to the numeric version id the upload client sends back, and that id back to the rockspec (VersionID and VersionFile).
- Driven: the format hooks' environment (format.Env): its blobs hold the files; its store holds the items, their properties and the package index (artifacts/core/pkgindex), which Reindex rebuilds from an AQL search of the stored files; its work queue takes the manifest work (Enqueue); and Derive writes each manifest file. The generic deploy policy (artifacts/ecosystem/generic), which Handler embeds, is the first check Admit applies, and a rock's ZIP is scanned within bounds by platform/archive.
- Settings: none.
Outputs ¶
- Handler: the hooks that check a file once before its transaction (Inspect); admit only a valid rockspec or rock at a valid root file name (Admit); set a stored file's properties, sync its version and queue the manifest (Deployed); queue the manifest for a delete (Deleting) and sync the versions a delete touched (Deleted); keep a file's .asc signature with it (Sidecars); name the manifest work a manifest read waits for (WorkKinds and Owed) and queue a missing manifest when it is read (Resolve); class the manifest files as derived (Classify); rebuild the index (Reindex); and write the manifests (Work).
- The package index: a package per name, with a version per <version>-<revision>, whose files are its rockspec and rocks.
- The luarocks.name, luarocks.version, luarocks.revision and luarocks.arch item properties (PropName, PropVersion, PropRevision and PropArch) on each stored file.
- The manifest files: manifest, and manifest-5.1 to manifest-5.5, each filtered by the simple Lua version constraints of the matching rockspec, written as Lua assignments in luarocks-admin's form.
- The rules the protocol shares: Identity, Parse, ValidateContent, VersionID, VersionFile, ManifestPath and KindManifest.
Invariants ¶
- Only the flat root layout the native client searches is indexed: a file name is <name>-<version>-<revision> with .rockspec or .<arch>.rock, and the trailing revision belongs to the version.
- A rockspec is at most 1 MiB with no NUL byte, and assigns package and version once each, matching its file name. A rock is a ZIP of at most 10,000 entries and 256 MiB unpacked, holding only regular files and folders at clean paths, every entry read to its end, and an embedded <name>-<version>.rockspec that passes the same check.
- Only content that breaks those rules is refused. A stored rockspec or rock that cannot be read is no fault of the file: the read's error returns as it is and fails the write (500).
- The manifests are derived only in local and federated repositories, never in a remote's cache, and hold at most 100,000 entries and 32 MiB. A manifest read there waits for owed work, and a read of a missing manifest queues it.
- Names and versions are quoted in a manifest, never evaluated as Lua source.
- The items keep the property names, so they never change; their exact 7.x spelling is inferred and recorded on #216.
References ¶
- Decision 0032: docs/research/decisions/0032-package-format-handlers.md (the format hooks); decision 0007: docs/research/decisions/0007-remote-repositories.md (remote repositories, whose upstream files ValidateContent checks); decision 0008: docs/research/decisions/0008-virtual-repositories.md (virtual repositories, which the protocol resolves over this index's members); decision 0033: docs/research/decisions/0033-persistent-work-queue.md (the manifest work).
- docs/testing/luarocks.md (the local, federated, remote and virtual qualification and the evidence), and docs/research/33-package-formats.md, "LuaRocks".
- JFrog LuaRocks repositories: https://docs.jfrog.com/artifactory/docs/luarocks-repositories, and the LuaRocks manifest writer: https://github.com/luarocks/luarocks/blob/main/src/luarocks/manif/writer.lua.
- Target layout: docs/research/architecture-options/5-modular-monolith.md, line 234 (ecosystem/luarocks), line 379 (the slice row) and line 997 (the mapping row).
- Plan: docs/implementation/plan.md#p9b-newly-identified-artifactory-formats and #p9d-modular-monolith-migration, epic ECO (https://github.com/weaveplatform/artifactweave/issues/943).
- https://github.com/weaveplatform/artifactweave/issues/684, https://github.com/weaveplatform/artifactweave/issues/685, https://github.com/weaveplatform/artifactweave/issues/686 and https://github.com/weaveplatform/artifactweave/issues/1050
Status ¶
Implemented P9b (newly identified Artifactory formats). Moved here in P9d.
Testing ¶
- luarocks_test.go: identity and rockspec admission, and a manifest the native client reads as Lua assignments.
- edge_test.go: stored-content checks, the manifest hooks' boundaries, admission and manifest size bounds, read faults, a missing package or version, and a search fault that publishes no manifest.
- readfault_test.go: a rock whose content fails a read at any point, on a store with ReadAt or one that can only seek, returns the read's error, and bad rocks keep their 400 refusals.
- contract_test.go (external, luarocks_test): the format contract (artifacts/core/formattest) and the public registry's dotted package names.
Index ¶
- Constants
- func Serves(t repo.PackageType) bool
- func ValidateContent(ctx context.Context, rc io.ReadSeeker, size int64, id Identity) error
- func VersionID(ctx context.Context, st format.Store, c repo.Config, id Identity) (int64, error)
- type Handler
- func (Handler) Admit(ctx context.Context, env format.Env, c repo.Config, w format.Write) (format.Write, error)
- func (Handler) Classify(_ repo.Config, path string) format.Class
- func (Handler) Deleted(ctx context.Context, env format.Env, c repo.Config, removed []model.Item) error
- func (Handler) Deleting(ctx context.Context, env format.Env, c repo.Config, it model.Item) error
- func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it model.Item) error
- func (Handler) Inspect(ctx context.Context, env format.Env, _ repo.Config, w format.Write) (any, error)
- func (Handler) Owed(c repo.Config, cached bool, path string) []format.WorkRef
- func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error
- func (Handler) Resolve(ctx context.Context, env format.Env, c repo.Config, d format.Download) (string, error)
- func (Handler) Sidecars(_ repo.Config, p string) []string
- func (Handler) Work(ctx context.Context, env format.Env, work work.WorkItem) error
- func (Handler) WorkKinds() []string
- type Identity
Constants ¶
const ( // KindManifest is the work kind that rebuilds a repository's manifest // files, keyed by the repository. The persistent work queue stores it // with each item, so it never changes. KindManifest = "luarocks.manifest" // ManifestPath is the path of the plain manifest at the repository root; // the Lua version variants are manifest-5.1 to manifest-5.5. ManifestPath = "manifest" // PropName is the property that holds a file's package name. The items // keep this name and the other luarocks.* names below, so they never // change. PropName = "luarocks.name" // [I] exact 7.161.32 property spelling: #216 // PropVersion is the property that holds a file's version, its revision // included. PropVersion = "luarocks.version" // PropRevision is the property that holds a file's revision. PropRevision = "luarocks.revision" // PropArch is the property that holds a rock's architecture, or // rockspec for a rockspec. PropArch = "luarocks.arch" )
Variables ¶
This section is empty.
Functions ¶
func Serves ¶
func Serves(t repo.PackageType) bool
Serves reports whether t is the LuaRocks package type.
func ValidateContent ¶
ValidateContent checks complete rock bytes before a remote cache publishes them. The same admission rules protect local uploads and remote downloads. Content that breaks them is refused with a format.RejectionError; a read of rc that fails is no fault of the rock, and returns as a plain error, which a write answers 500.
Types ¶
type Handler ¶
Handler is the LuaRocks format's hooks: it admits a rockspec or rock only at a valid root file name with a rockspec that matches it, indexes each stored file as a version of its package, keeps a file's .asc signature with it, and has the work queue derive the manifest files of local and federated repositories. It embeds the generic hooks.
func (Handler) Admit ¶
func (Handler) Admit( ctx context.Context, env format.Env, c repo.Config, w format.Write, ) (format.Write, error)
Admit applies the generic deploy policy, wrapping its refusal, then passes a checksum deploy and a write to a remote's cache. Any other write of a .rockspec or .rock must use a valid root file name (400), and its content must pass ValidateContent; Admit reuses Inspect's check when it covers the same content and file name, and checks the stored content itself otherwise. Other files pass.
func (Handler) Classify ¶
Classify classes the manifest files as derived, so replication and federation skip them and each side builds its own, and every other path as unique content.
func (Handler) Deleted ¶
func (Handler) Deleted( ctx context.Context, env format.Env, c repo.Config, removed []model.Item, ) error
Deleted syncs each version a delete touched from its files still stored. A version left without files needs nothing: the item service has already unlinked and pruned it.
func (Handler) Deleting ¶
Deleting queues the manifest work when a rockspec, rock or manifest file of a local or federated repository is about to be deleted; folders and other files change nothing.
func (Handler) Deployed ¶
Deployed indexes a stored file at a valid root file name in the tree the package index reads: it sets the file's luarocks.* properties, syncs its version from every stored file of that version, and queues the manifest work, as a stored manifest file does too. Folders and other items change nothing, and the work is queued only in a local or federated repository.
func (Handler) Inspect ¶
func (Handler) Inspect( ctx context.Context, env format.Env, _ repo.Config, w format.Write, ) (any, error)
Inspect checks the stored content of a write to a valid root file name (Parse) before the write's transaction, so Admit need not check it again. A write to any other path, or without content, inspects nothing. Content that fails ValidateContent is refused (400, or 413 for a rockspec over 1 MiB); content that cannot be opened or read fails the write (500).
func (Handler) Owed ¶
Owed names the manifest work that a download of a manifest file from a local or federated repository must see done first, so a client never reads a manifest that lags a completed write; other downloads owe nothing.
func (Handler) Reindex ¶
Reindex rebuilds the package index in one transaction from every stored rockspec and rock at a valid root file name in the tree the index reads: it checks each file's content again, sets its properties, groups the files by package and version, reconciles the index and queues the manifest work. A file whose content no longer passes fails the reindex.
func (Handler) Resolve ¶
func (Handler) Resolve( ctx context.Context, env format.Env, c repo.Config, d format.Download, ) (string, error)
Resolve leaves every path as it is. When a download asks for a manifest file of a local or federated repository that holds neither the file nor queued manifest work, it queues the work, which Owed then makes the download wait for. A store or work queue fault fails the download.
func (Handler) Sidecars ¶
Sidecars names the .asc signature that a rockspec or rock at a valid root file name owns, so the item service deletes, copies, moves and restores it with its owner; other files own none.
type Identity ¶
type Identity struct{ Name, Version, Revision, Arch string }
Identity is the package coordinate read from a flat LuaRocks filename.
func Parse ¶
Parse accepts only the root layout the native client searches. The final -revision is part of LuaRocks' version, not a separate indexed version.
func VersionFile ¶
func VersionFile( ctx context.Context, st format.Store, c repo.Config, wanted int64, ) (Identity, error)
VersionFile resolves the numeric version id returned to the native upload client. It returns the rockspec's flat filename and refuses a version that has since been deleted. Scanning packages avoids ephemeral server state.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package luarockshttp serves local and federated LuaRocks repositories through the native flat rocks-server URL and the native upload API, and remote and virtual ones through the same URL, on Artifactory's /artifactory/api/luarocks/{repo} prefix: the manifest files and the rockspecs and rocks they name, and the upload client's tool version, rockspec check and rockspec and rock uploads.
|
Package luarockshttp serves local and federated LuaRocks repositories through the native flat rocks-server URL and the native upload API, and remote and virtual ones through the same URL, on Artifactory's /artifactory/api/luarocks/{repo} prefix: the manifest files and the rockspecs and rocks they name, and the upload client's tool version, rockspec check and rockspec and rock uploads. |