package resolution import ( "encoding/json" mcat "git.novox.be/novox/mesh-sdk/go/catalogue" ) // LaidSource says whether a value resolved from source is laid over a module's files: mesh config, node config and the // module's own value are; a manifest's default is not, since it is the composition's already and a taken key is laid // only when a layer sets it, never from a default (TakesSettingsField); an unset value is not, since a required one is // refused by the composition by name. **The one rule for every composer** (issue 1126, C2): the controller's config // read and a node composing its own lay the same values, so the two compose the same files. func LaidSource(source string) bool { switch source { case mcat.SourceMesh, mcat.SourceNode, mcat.SourceModule: return true } return false } // LaidValue is one key of mesh-config_resolved read as a composer lays it: its value, and true when its source is laid // (LaidSource) and it holds a value; false for a default, an unset value, a source not known and a value that cannot be // read. func LaidValue(raw []byte) (any, bool) { var r struct { Value json.RawMessage `json:"value"` Source string `json:"source"` } if json.Unmarshal(raw, &r) != nil || !LaidSource(r.Source) || len(r.Value) == 0 { return nil, false } var v any if json.Unmarshal(r.Value, &v) != nil { return nil, false } return v, true }