package index import ( "encoding/json" "git.novox.be/novox/mesh-sdk/go/catalogue" ) // readManifest reads a manifest as the catalogue's parser does, for the inputs of its fingerprint (issue 1751). A config // value falling back to a predefined key (novox/hq ADR 0348 ยง7) is judged against the list the mesh published when the // process holds one; the indexer holds none, since the list is read where a manifest is judged (the merge gate, from the // tree's root) and by the controller, so each key a value names is taken as the value declares it: of its type, trusted // when it is. What the list adds is the judging of the value, which the gate and the controller do; no input of a // fingerprint comes from it. Everything else the parser refuses is refused here too. func readManifest(raw []byte) (catalogue.Manifest, error) { list := catalogue.PublishedPredefined() if list == nil { list = fallbacksOf(raw) } return catalogue.ParseManifestWith(raw, list) } // fallbacksOf is the list of the predefined keys the manifest's config values fall back to, each as the value declares // it. A manifest that is not JSON gives an empty list, and the parser says what is wrong with it. func fallbacksOf(raw []byte) catalogue.PredefinedList { var m struct { Config map[string]struct { Type string `json:"type"` Description string `json:"description"` Predefined string `json:"predefined"` Trusted bool `json:"trusted"` } `json:"config"` } list := catalogue.PredefinedList{} if json.Unmarshal(raw, &m) != nil { return list } for _, d := range m.Config { if d.Predefined != "" { list[d.Predefined] = catalogue.PredefinedKey{Type: d.Type, Description: d.Description, Trusted: d.Trusted} } } return list }