packages

package
v0.1.71 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 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 packages is the module packages api holds (R07, R41): the release of modules that modules.json pins and the digest of its index, the command that lays the packages of that index which are in api's window into a folder — the image's, or the first app's outside git — and the reading of that folder when serve starts. module-kit checks each package by the chain of digests from the index; the index itself is held by its digest, which the pull request that pinned it checked against its signature (R77 spec).

Index

Constants

View Source
const DefaultBase = "https://github.com/altnovatrail/modules/releases/download"

DefaultBase is where the releases of modules give their files, without a token: /<release>/<file> follows it.

View Source
const (
	IndexFile = moduleindex.File
)

The layout of the folder (R07, R41): the pinned index; the three files of each package's chain under the digest of the package; and each file of a device part once, under its own digest, so that a medium the next version keeps takes no room.

Variables

View Source
var (
	// ErrOlderRelease is a release older than the one main pins: a withdrawal is
	// marked only in the indexes of the releases after it (R63 spec).
	ErrOlderRelease = errors.New("packages: the release is older than the one main pins")
	// ErrLostVersion is a module that has a current version on main and would have
	// none, other than by a withdrawal (R07).
	ErrLostVersion = errors.New("packages: a module would lose its current version")
	// ErrNewestIndex is a file of the newest release of modules that is no module
	// index (R61).
	ErrNewestIndex = errors.New("packages: the newest release gives no module index")
)

The reasons Check refuses a modules.json, beside ErrIndex, and the one of Withdrawals.

View Source
var (
	// ErrIndex is an index whose bytes are not those of the digest modules.json
	// pins, or no index of the format.
	ErrIndex = errors.New("packages: not the index modules.json pins")
	// ErrFetch is a file of the release that could not be fetched: an answer that
	// is not 200, or more bytes than its limit.
	ErrFetch = errors.New("packages: the file could not be fetched from the release")
	// ErrArchive is an archive of a package that holds what a package does not:
	// a link or another kind of entry, a sparse file, a path out of the package
	// or of no part of it, or more bytes than its limit (R41).
	ErrArchive = errors.New("packages: the archive is not a package's")
	// ErrNotEmpty is a folder to lay the packages into that holds something.
	ErrNotEmpty = errors.New("packages: the folder is not empty")
)

The reasons Lay and Read refuse, which their errors wrap.

View Source
var ErrConfig = errors.New("packages: modules.json is not a release and the digest of its index")

ErrConfig is a modules.json that is not the form R07 gives it.

View Source
var ErrNotListed = errors.New("packages: a module of the catalog's list is not in the pinned index")

ErrNotListed is an ID of the deployment's list of modules that the pinned index does not hold (R150 spec): a typo would hide a module without a word, so it is a failed start, as a fact the admission table does not name is.

Functions

func FromName added in v0.1.13

func FromName(name string) (digest formatv0.Digest, ok bool)

FromName is the digest whose Name name is; ok is false when name is no such name.

func IsDigest added in v0.1.13

func IsDigest(s string) bool

IsDigest says whether s is a digest as the format and the contract write one: sha256: and 64 lowercase hexadecimal digits.

func Name added in v0.1.13

func Name(digest formatv0.Digest) string

Name is a digest as a name in the folder and in a release, and in the path of a file of a device part: sha256-<hex> (R99 spec).

func NotInIndex added in v0.1.48

func NotInIndex(index formatv0.ModuleIndex, ids []formatv0.ModuleID) error

NotInIndex refuses each of ids that index does not hold, naming them in their order: whether the deployment's list names only modules of the pinned index.

func ReadIndex added in v0.1.48

func ReadIndex(dir string, cfg Config) (formatv0.ModuleIndex, error)

ReadIndex reads the index of the folder dir that Lay laid for cfg, by the digest cfg pins, and none of its packages: what api check needs to check the deployment's list of modules against it.

Types

type Config

type Config struct {
	// Release is the tag of the release, vX.Y.Z.
	Release string `json:"release"`
	// Index is sha256: and 64 hexadecimal digits in lower case.
	Index formatv0.Digest `json:"index"`
}

Config is modules.json: the tag of a release of modules and the digest of the bytes of its module-index.json (R07).

func ParseConfig

func ParseConfig(data []byte) (Config, error)

ParseConfig reads modules.json: one object of the two members alone, each once and of its form, and nothing after it — so that what a reviewer reads in the file is what the binary pins.

type Current

type Current struct {
	ID      formatv0.ModuleID
	Version formatv0.ModuleVersion
	// OK is false when the module has no current version.
	OK bool
}

Current is the version of a module that a new attempt gets by an index: the newest in api's window that the index does not mark withdrawn, by module-kit (R07), or none.

func Check

func Check(cfg Config, index []byte, mainCfg *Config, mainIndex []byte) ([]Current, error)

Check is the check of CI of a modules.json, cfg, whose signature the job has checked by release-verify (R07; R77 spec): index must be the bytes of its index; and against main's — mainCfg and mainIndex, or nil when main pins none — its release must not be older, and no module that has a current version on main may lose it other than by a withdrawal. It gives the current version of each module of either index, so that the author sees what the learners get.

type Laid

type Laid struct {
	Packages int
	Files    int
}

Laid is what Lay laid: the packages and the files of their device parts, each counted once.

func Lay

func Lay(ctx context.Context, src Source, cfg Config, dir string) (Laid, error)

Lay fetches the index of the release cfg pins, checks it by its digest, and lays each package of the index in api's window into dir, withdrawn ones too — a withdrawn version is kept to repeat a verdict (R63 spec; R07). Each package is fetched as its archive from the release its entry names, unpacked in memory, read by module-kit by the chain from its digest, and only the files the chain names are written. dir is made afresh beside where it is, and is there whole or not at all: it may not hold anything already.

type Set

type Set struct {
	// Release is the release of modules that modules.json pins.
	Release string
	// Index is its index.
	Index formatv0.ModuleIndex
	// Packages is each package of the index in the window, withdrawn ones too:
	// its inventory, canonical view and listing.
	Packages map[formatv0.Digest]*modulepackage.Package
	// Dir is the folder.
	Dir string
	// contains filtered or unexported fields
}

Set is the packages a folder holds, as serve reads them at its start: the pinned index and each package of it in api's window, by its digest. A package holds its three texts, read by module-kit by the chain of digests from the index; the files of its device part stay in the folder, each under its own digest, which package catalog serves (R42).

func Read

func Read(dir string, cfg Config) (*Set, error)

Read reads the folder dir that Lay laid for cfg: its index must have the digest cfg pins, so that a folder of another release is a failed start rather than another set of versions (R41), and each package of that index in the window must be there: its texts whole, by the chain of digests from the index, and each file its listing names, of the size it names. The files of the device parts are not read again: Lay laid each under its digest after module-kit had read it, and an image does not change; so serve holds no media in memory and does not hash them at every start.

func (*Set) Current added in v0.1.13

func (s *Set) Current(id formatv0.ModuleID) (pkg *modulepackage.Package, ok bool)

Current is the package of the current version of the module id: the newest by semver of its versions the index does not mark withdrawn and whose format version is in the window, by module-kit (R07). ok is false when it has none.

func (*Set) CurrentFor added in v0.1.15

func (s *Set) CurrentFor(id formatv0.ModuleID, category formatv0.AgeCategory) (*modulepackage.Package, bool)

CurrentFor is the package of the current version of the module id for a learner of category: none when the module has no current version, or one whose audience the learner is not in — the version is one for every learner, and an older one is never given instead (R07).

func (*Set) DeviceFile added in v0.1.13

func (s *Set) DeviceFile(digest formatv0.Digest, path string) (name string, file formatv0.Digest, ok bool)

DeviceFile is the file of the device part of the package of digest at path, as its listing names it — LICENSE, NOTICE or media/<path> — by its path in the folder and its own digest. ok is false when the package is none the set holds, or its device part has no such path.

func (*Set) File

func (s *Set) File(digest formatv0.Digest) string

File is the path in the folder of the file of a device part of digest.

func (*Set) List added in v0.1.48

func (s *Set) List(ids []formatv0.ModuleID) error

List narrows what the set offers to the modules ids, the deployment's list (R150 spec): the catalog gives no other module, and the engine chooses none of its lessons and tasks, as of a module with no current version. Their packages stay in the set, so an attempt or a lesson run open on one goes on to its end on its package (R13). An ID the index does not hold is refused, and the set is left as it was; with no list — ids nil — the set offers the whole index. It is called before the set is served, as serve calls it at its start: the handlers read the list with no lock.

func (*Set) Listed added in v0.1.48

func (s *Set) Listed(id formatv0.ModuleID) bool

Listed says whether the deployment's list names the module id, or there is no list.

func (*Set) Modules added in v0.1.13

func (s *Set) Modules() []formatv0.ModuleID

Modules is the ID of each module the index names, in the order of their bytes.

func (*Set) Names added in v0.1.13

func (s *Set) Names(id formatv0.ModuleID) bool

Names says whether the index names the module id.

func (*Set) NotGiven added in v0.1.20

func (s *Set) NotGiven() []string

NotGiven is every digest the image no longer gives, in the order of their bytes: those whose attempts and lesson runs the job after a rollout closes "unchecked" (R07).

func (*Set) OfferedFor added in v0.1.48

func (s *Set) OfferedFor(id formatv0.ModuleID, category formatv0.AgeCategory) (*modulepackage.Package, bool)

OfferedFor is CurrentFor of a module the deployment's list names: the package a new attempt, a new lesson run, the catalog and the engine take (R150 spec).

func (*Set) Status added in v0.1.13

func (s *Set) Status(digest formatv0.Digest) Status

Status is whether the image gives the package of digest. A digest that two entries name is given when either gives it.

func (*Set) Teachers added in v0.1.26

func (s *Set) Teachers(category formatv0.AgeCategory) map[formatv0.AnchorSkillID][]formatv0.ModuleID

Teachers is, by each anchor skill, the ID of each module whose current version for a learner of category names it in teaches of its entry of the index, in the order of their bytes (R63 spec), among those the deployment's list names (R150 spec).

type Source

type Source struct {
	// Client fetches; nil is a client of its own, with fetchTimeout.
	Client *http.Client
	// Base is DefaultBase, or a test's server.
	Base string
}

Source is where Lay fetches the files of the releases.

type Status added in v0.1.13

type Status int

Status is whether the image gives a package (R07).

const (
	// Unknown is a digest the index of the image does not know: a deployment is
	// going on, or the digest is no package's.
	Unknown Status = iota
	// Given is a package of a version the index does not mark withdrawn, whose
	// format version is in api's window.
	Given
	// NotGiven is a package the index knows, of a version it marks withdrawn or
	// out of the window.
	NotGiven
)

The statuses of a digest.

type Withdrawal added in v0.1.28

type Withdrawal struct {
	ID      formatv0.ModuleID
	Version formatv0.ModuleVersion
	Reason  formatv0.WithdrawalReason
	// Current is true when the version is the current version by the pinned index.
	Current bool
}

Withdrawal is a version that the pinned release gives and the newest release withdraws: until modules.json pins a release that marks it, it stays given, and new attempts take it when it is the current version (R07; R61).

func Withdrawals added in v0.1.28

func Withdrawals(cfg Config, index, latest []byte) ([]Withdrawal, error)

Withdrawals is the check of the scheduled job Withdrawals (R61): index must be the bytes of the index cfg pins, and latest the index of the newest release of modules, whose signature the job has checked by release-verify (R77 spec). It gives each version that the pinned index gives — in api's window, and not withdrawn — and that latest withdraws, by module ID and then by version, each in the order of its bytes. Only the newest index knows of every withdrawal so far, and module-kit joins them to the pinned index (moduleindex.WithLatest): an index that does not keep every entry of the pinned one, as one of an older release, gives an error that is moduleindex.ErrLatest.

Directories

Path Synopsis
Package packagestest builds, for the tests, what package packages lays and reads: the packages of the vectors of spec's format, their archives, an index of them and a release of modules that serves them, and a folder laid from them, read as serve reads it (R41).
Package packagestest builds, for the tests, what package packages lays and reads: the packages of the vectors of spec's format, their archives, an index of them and a release of modules that serves them, and a folder laid from them, read as serve reads it (R41).

Jump to

Keyboard shortcuts

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