Files
mesh-sdk/go/delivery/provided.go
T
jschoubben 5228a5782d
mesh/delivery merged: source.main moved to novox/mesh-sdk@6b43afa2ab38
mesh/delivery-group group fix/1126-provided merged: every member is merged
mesh/check checking 5228a5782d5c on d7c790d2422c | novox/mesh-sdk#120 in group fix/1126-provided
Name the modules the mesh provides itself in one predicate, so the seed's check takes the private network as the composer and the grants part do (issue 1126)
2026-10-28 20:12:51 +01:00

38 lines
1.6 KiB
Go

package delivery
import (
"encoding/json"
"fmt"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/overlay"
)
// The modules the mesh provides itself (issue 1126): no repository holds them, so the indexer reads none; their
// manifests come with mesh-sdk, built in code, and always win over any other. Today the private network alone
// (overlay.Name), built by nobody and run inside each node's own composition. One predicate for every part that judges
// or composes a placement: CheckPlacements, the seat's holder, the composer's input (frombus) and the grants part.
// ProvidedModules is every module the mesh provides itself, sorted.
func ProvidedModules() []string { return []string{overlay.Name} }
// ProvidedByMesh says whether the mesh provides module itself, so a placement may name it with no repository holding it.
func ProvidedByMesh(module string) bool { return module == overlay.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("delivery: the mesh provides no module %s", module)
}
raw, err := json.Marshal(overlay.Manifest())
if err != nil {
return catalogue.Manifest{}, nil, err
}
m, err := catalogue.ParseManifestForInputs(raw)
if err != nil {
return catalogue.Manifest{}, raw, fmt.Errorf("delivery: the manifest mesh-sdk provides for %s is refused by its own reader: %w", module, err)
}
return m, raw, nil
}