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 }