38 lines
1.6 KiB
Go
38 lines
1.6 KiB
Go
package overlay
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// The modules the mesh provides itself (issue 1126): no repository holds them, so the indexer reads none; their
|
|
// manifests are built in code, here, and always win over any other. Today the private network alone, built by nobody
|
|
// and run inside each node's own composition. One predicate for every part that judges or composes an assignment: the
|
|
// assignment's check, the seat's holder, the composer's input and the grants part.
|
|
|
|
// ProvidedModules is every module the mesh provides itself, sorted.
|
|
func ProvidedModules() []string { return []string{Name} }
|
|
|
|
// ProvidedByMesh says whether the mesh provides module itself, so an assignment may name it with no repository holding it.
|
|
func ProvidedByMesh(module string) bool { return module == Name }
|
|
|
|
// ProvidedManifest is a provided module's manifest, as its readers parse it, and its raw JSON; an error for a module the
|
|
// mesh does not provide or a manifest its own reader refuses.
|
|
func ProvidedManifest(module string) (catalogue.Manifest, []byte, error) {
|
|
if !ProvidedByMesh(module) {
|
|
return catalogue.Manifest{}, nil, fmt.Errorf("overlay: the mesh provides no module %s", module)
|
|
}
|
|
raw, err := json.Marshal(Manifest())
|
|
if err != nil {
|
|
return catalogue.Manifest{}, nil, err
|
|
}
|
|
// Decoded as every reader decodes a manifest (novox/hq ADR 0578 §3); its judgement is the indexer's.
|
|
m, err := catalogue.Decode(raw)
|
|
if err != nil {
|
|
return catalogue.Manifest{}, raw, fmt.Errorf("overlay: the manifest the mesh provides for %s does not decode: %w", module, err)
|
|
}
|
|
return m, raw, nil
|
|
}
|