modulepackage

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 15 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 modulepackage builds the package of a checked module — its canonical view, the listing of its device part and its inventory, with their digests — and reads a package as files by the chain of digests from the digest an index gives: inventory, then parts, then files. It checks no signature: spec's release-verify does, where a file enters NovaTrail. The CLI's build, api, tutor's eval runner and module-registry call it.

Build checks a module by package module and builds its package — the canonical view, with the tiers of its skill graph and the numbers of every instance of its templates with the results of their solvers, the listing of the device part and the inventory, each by its canonical text from internal/canonical — as bytes of its files; the CLI writes them to a folder. Read takes the files of a package as an fs.FS and the digest of the package, and reads the inventory by that digest, then the two parts, then the files of device/, each by the digest and size that name it, held to its schema and its canonical text.

Index

Constants

View Source
const (
	InventoryFile = "inventory.json"
	ServerFile    = "server.json"
	DeviceFile    = "device.json"
	DeviceFolder  = "device/"
)

The files of a package as files, by their paths in its folder: the canonical texts of the inventory, the canonical view and the listing of the device part, and the folder of the device part's files, byte for byte.

Variables

View Source
var (
	// ErrChain is a file that is not the one the chain of digests names: its digest or its size is
	// not the one the digest of the package, the inventory or the listing gives it, or it is missing.
	ErrChain = errors.New("not the file the chain of digests names")
	// ErrFormatVersion is a package of a format version that module-kit does not read.
	ErrFormatVersion = errors.New("a format version module-kit does not read")
	// ErrNotCanonical is a file of a package that is not the canonical text of a value valid against
	// its schema, or an inventory that names another module than its canonical view does.
	ErrNotCanonical = errors.New("not what the format builds")
)

The reasons Read refuses a package, which its error wraps with the file it refuses.

Functions

This section is empty.

Types

type Package

type Package struct {
	Digest    formatv0.Digest
	Inventory formatv0.Inventory
	View      formatv0.CanonicalView
	Listing   formatv0.DeviceListing
	Files     map[string][]byte
}

A Package is the package of a module: its digest, its inventory, its canonical view, the listing of its device part, and its files, by their paths in the folder of a package as files, each byte for byte as the folder holds it: InventoryFile, ServerFile, DeviceFile, and under DeviceFolder LICENSE, NOTICE when the module has one, and media/<path> for each media file.

func Build

func Build(ctx context.Context, fsys fs.FS) (*Package, error)

Build builds the package of the module whose folder is the root of fsys, by the format version its manifest names. It checks the module first, and a module that breaks the format gives a *Refusal with the report of its check. The solver of each template runs once, in the check, with ctx and one on each CPU, as module.Check runs them, and an error of ctx comes back as it is. Any other error is a file that could not be read, or a fault of module-kit: of a module that passed its check, the canonical text refuses nothing.

The package depends on the files of the module and on the format version alone: its files and folders whose names begin with ".", the eval set, eval/, and the comments of its files of parts stay out, and nothing is added — no version of module-kit, no time, no path.

func Read

func Read(fsys fs.FS, digest formatv0.Digest) (*Package, error)

Read reads a package as files, the folder at the root of fsys, by the chain of digests from the digest of the package that a checked index gives: inventory.json by that digest, then server.json and device.json by the digests and sizes the inventory gives, then each file of device/ by those the listing gives. A file is read only once the one before it in the chain has named it, and each is held to its schema and to its canonical text, so a package that Read accepts is the one Build built. Read checks no signature: the index was checked where it entered NovaTrail. A file of the folder that the chain does not name is no part of the package, and Read does not read it.

It reads a package of the format version that module-kit reads, FormatVersion of package module; of another, it gives ErrFormatVersion as soon as the inventory names it. Its errors wrap ErrChain, ErrFormatVersion or ErrNotCanonical, with the file they are of, or are those of fsys.

func ReadParts added in v0.1.23

func ReadParts(fsys fs.FS, digest formatv0.Digest) (*Package, error)

ReadParts reads a package as files as Read does, by the chain of digests from the digest of the package, but without the files of device/: its inventory, its canonical view and the listing of its device part, which names each of those files by its digest and size. So the comparison of the versions of a module reads a published package, whose device part it compares by its listing. Files then holds InventoryFile, ServerFile and DeviceFile alone. Its errors are those of Read.

type Refusal

type Refusal struct {
	Report module.Report
}

A Refusal is why Build builds no package: the module breaks the format, and the report of its check names every breach.

func (*Refusal) Error

func (r *Refusal) Error() string

Jump to

Keyboard shortcuts

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