Documentation
¶
Overview ¶
Package packages is the module packages api holds: 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.
Index ¶
- Constants
- Variables
- func FromName(name string) (digest formatv0.Digest, ok bool)
- func IsDigest(s string) bool
- func Name(digest formatv0.Digest) string
- func NotInIndex(index formatv0.ModuleIndex, ids []formatv0.ModuleID) error
- func ReadIndex(dir string, cfg Config) (formatv0.ModuleIndex, error)
- type Config
- type Current
- type Laid
- type Set
- func (s *Set) Current(id formatv0.ModuleID) (pkg *modulepackage.Package, ok bool)
- func (s *Set) CurrentFor(id formatv0.ModuleID, category formatv0.AgeCategory) (*modulepackage.Package, bool)
- func (s *Set) DeviceFile(digest formatv0.Digest, path string) (name string, file formatv0.Digest, ok bool)
- func (s *Set) File(digest formatv0.Digest) string
- func (s *Set) List(ids []formatv0.ModuleID) error
- func (s *Set) Listed(id formatv0.ModuleID) bool
- func (s *Set) Modules() []formatv0.ModuleID
- func (s *Set) Names(id formatv0.ModuleID) bool
- func (s *Set) NotGiven() []string
- func (s *Set) OfferedFor(id formatv0.ModuleID, category formatv0.AgeCategory) (*modulepackage.Package, bool)
- func (s *Set) Status(digest formatv0.Digest) Status
- func (s *Set) Teachers(category formatv0.AgeCategory) map[formatv0.AnchorSkillID][]formatv0.ModuleID
- type Source
- type Status
- type Withdrawal
Constants ¶
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.
const (
IndexFile = moduleindex.File
)
The layout of the folder: 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 ¶
var ( // ErrOlderRelease is a release older than the one main pins: a withdrawal is // marked only in the indexes of the releases after it. 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. 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. 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.
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. 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.
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 of the form of Config.
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: 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
FromName is the digest whose Name name is; ok is false when name is no such name.
func IsDigest ¶ added in v0.1.13
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
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>.
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.
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.
func ParseConfig ¶
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, or none.
func Check ¶
Check is the check of CI of a modules.json, cfg, whose signature the job has checked by release-verify: 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 ¶
Laid is what Lay laid: the packages and the files of their device parts, each counted once.
func Lay ¶
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. 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.
func Read ¶
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, 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
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. 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.
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) List ¶ added in v0.1.48
List narrows what the set offers to the modules ids, the deployment's list: 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. 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
Listed says whether the deployment's list names the module id, or there is no list.
func (*Set) Modules ¶ added in v0.1.13
Modules is the ID of each module the index names, in the order of their bytes.
func (*Set) NotGiven ¶ added in v0.1.20
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".
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.
func (*Set) Status ¶ added in v0.1.13
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, among those the deployment's list names.
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.
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.
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: 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. 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.
|
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. |