Seals are reused and compared by slot (resource, field), never across resources; one rule says which resolved config values are laid; a seat path that steps back is owned by the seat it steps back for, whatever the seat order; a folded module of an old-form build is composed from what runs of it; the operator export's file is carried as it runs; a differing resource names its differing JSON paths, found before its bodies are cut, and an answer is fitted to the node's key.
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package catalogue
|
|
|
|
import "encoding/json"
|
|
|
|
// The sources mesh-config says a resolved value came from, in mesh-config_resolved (novox/hq ADR 0348 §9): a key of
|
|
// it holds {"value": …, "source": …}.
|
|
const (
|
|
SourceMesh = "mesh"
|
|
SourceNode = "node"
|
|
SourceModule = "module"
|
|
SourceDefault = "default"
|
|
SourceUnset = "unset"
|
|
)
|
|
|
|
// 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 SourceMesh, SourceNode, 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
|
|
}
|