82 lines
4.1 KiB
Go
82 lines
4.1 KiB
Go
package catalogue
|
|
|
|
import "encoding/json"
|
|
|
|
// CatalogSeat is the seat of the catalog: what the mesh holds of every module (novox/hq ADR 0604 §1). Its states are
|
|
// its holder's: the modules the trunk holds, their manifests by digest and the module graph (the indexer's states
|
|
// `modules`, `manifests` and `graph`), announced with who may read them; a reader that only watches reads them and calls
|
|
// no verb. It names no event. What must be built again is no verb: a module whose fingerprint differs from its newest
|
|
// build, which the delivery view derives. The verbs' answers are CatalogModules, CatalogOne, CatalogProvides and
|
|
// CatalogDependents, whose field names are those of the catalog module's tools they replace.
|
|
const CatalogSeat = "mesh-catalog"
|
|
|
|
// catalogVerbs are the seat's four verbs, each read from its holder's states. Each is optional until the holder that
|
|
// runs serves it (design 33 §7): the module that claimed the seat before serves none of them, and a judge holding them
|
|
// required would read it as outgrown for as long as both claims stand (novox/hq ADR 0604 §6).
|
|
func catalogVerbs() []Verb {
|
|
return []Verb{
|
|
{Name: "modules", Optional: true, Description: "Every module the trunk holds, each with its repository, its " +
|
|
"directory there, the merge commit it was last changed at and its fingerprint (or why it has none): the " +
|
|
"catalog of the mesh, read from its holder's state. Reads only.",
|
|
Input: schema(map[string]string{}, nil)},
|
|
{Name: "module", Optional: true, Description: "One module whole: its repository, directory, commit and " +
|
|
"fingerprint, and its manifest as the trunk holds it. Older versions are in its repository's history. Reads only.",
|
|
Input: schema(map[string]string{"module": "the module's name"}, []string{"module"})},
|
|
{Name: "provides", Optional: true, Description: "Which modules provide a provision (a module provides its own " +
|
|
"name too) and which require it, from the module graph's provision edges. Reads only.",
|
|
Input: schema(map[string]string{"provision": "the provision, such as postgres-database"}, []string{"provision"})},
|
|
{Name: "dependents", Optional: true, Description: "The modules whose build edges reach a module, directly or " +
|
|
"through others (a base, a mesh package it publishes, the build module that builds them): what a change of it " +
|
|
"builds again, from the module graph. Reads only.",
|
|
Input: schema(map[string]string{"module": "the module's name"}, []string{"module"})},
|
|
}
|
|
}
|
|
|
|
// CatalogEntry is one module of the catalog: its repository, its directory there ("." for the root), the merge commit it
|
|
// was last changed at, and its new-form fingerprint or why it has none.
|
|
type CatalogEntry struct {
|
|
Module string `json:"module"`
|
|
Repository string `json:"repository"`
|
|
Path string `json:"path"`
|
|
Commit string `json:"commit"`
|
|
FP string `json:"fp,omitempty"`
|
|
None string `json:"none,omitempty"`
|
|
}
|
|
|
|
// CatalogModule is one module whole: its entry and its manifest as the trunk holds it.
|
|
type CatalogModule struct {
|
|
CatalogEntry
|
|
Manifest json.RawMessage `json:"manifest"`
|
|
}
|
|
|
|
// CatalogEnd is a module that provides, requires or depends on something, with its commit; Scope is a provider's scope
|
|
// (a module provides its own name at node scope).
|
|
type CatalogEnd struct {
|
|
Module string `json:"module"`
|
|
Commit string `json:"commit"`
|
|
Scope string `json:"scope,omitempty"`
|
|
}
|
|
|
|
// CatalogModules is the answer of the verb modules: every module the trunk holds, sorted by name.
|
|
type CatalogModules struct {
|
|
Modules []CatalogEntry `json:"modules"`
|
|
}
|
|
|
|
// CatalogOne is the answer of the verb module.
|
|
type CatalogOne struct {
|
|
Module CatalogModule `json:"module"`
|
|
}
|
|
|
|
// CatalogProvides is the answer of the verb provides: the modules that provide the provision and those that require it.
|
|
type CatalogProvides struct {
|
|
Provision string `json:"provision"`
|
|
Provides []CatalogEnd `json:"provides"`
|
|
Requires []CatalogEnd `json:"requires"`
|
|
}
|
|
|
|
// CatalogDependents is the answer of the verb dependents: the modules whose build edges reach the module.
|
|
type CatalogDependents struct {
|
|
Module string `json:"module"`
|
|
Dependents []CatalogEnd `json:"dependents"`
|
|
}
|