Add strict custom field registry

This commit is contained in:
2026-05-07 11:04:11 +08:00
parent 27e71d8c51
commit c1cc9132a4
20 changed files with 582 additions and 20 deletions

View File

@@ -33,6 +33,11 @@ func LoadProject(root string) (*Project, error) {
project.LoadIssues = append(project.LoadIssues, Issue{Level: "error", Code: "manifest_error", File: "gsp.manifest", Message: err.Error()})
}
project.Manifest = manifest
fields, err := loadFieldRegistry(absRoot, project.Manifest)
if err != nil {
project.LoadIssues = append(project.LoadIssues, Issue{Level: "error", Code: "field_registry_error", File: project.Manifest.fieldRegistryPath(), Message: err.Error()})
}
project.Fields = fields
var files []string
for _, scanEntry := range project.Manifest.scanEntries() {
@@ -98,6 +103,14 @@ func readUnit(root, file string) (*Unit, error) {
if err := yaml.Unmarshal(data, &unit); err != nil {
return nil, err
}
var raw map[string]any
if err := yaml.Unmarshal(data, &raw); err != nil {
return nil, err
}
unit.RawFields = map[string]any{}
for key, value := range raw {
unit.RawFields[key] = normalizeRawYAML(value)
}
unit.File = relPath(root, file)
return &unit, nil
}