autogen activation
build-binaries / build-binaries (pull_request) Successful in 2m14s
test-image / build-image (pull_request) Successful in 45s
test / test (pull_request) Successful in 1m24s

This commit is contained in:
2026-06-21 01:20:27 +02:00
parent 97f4c00393
commit 3b10a3dd9f
3 changed files with 138 additions and 0 deletions
+34
View File
@@ -225,6 +225,9 @@ func autogenConsumerTargetsDataset(dataset nativeCollectedDataset, consumer proj
}
func resolveAutogenConsumerManifest(p *project.Project, consumer project.AutogenConsumerConfig, progress func(string)) (*autogenManifest, error) {
if manifestFile := strings.TrimSpace(consumer.ManifestFile); manifestFile != "" {
return readAutogenConsumerManifestFile(p, consumer, manifestFile, progress)
}
overrideRoot, err := resolveAutogenLocalOverrideRoot(p, consumer)
if err != nil {
return nil, err
@@ -242,6 +245,37 @@ func resolveAutogenConsumerManifest(p *project.Project, consumer project.Autogen
return resolveReleasedAutogenManifest(p, consumer, progress)
}
// readAutogenConsumerManifestFile reads a pre-resolved autogenManifest JSON from
// a local file (relative paths resolve against the project root). A missing file
// is an ignorable-optional condition — it returns errAutogenManifestUnavailable
// so an optional consumer fails open and preserves its pinned lock IDs. A present
// but malformed file, or an id that disagrees with the consumer's producer, is a
// hard error.
func readAutogenConsumerManifestFile(p *project.Project, consumer project.AutogenConsumerConfig, manifestFile string, progress func(string)) (*autogenManifest, error) {
path := manifestFile
if !filepath.IsAbs(path) {
path = filepath.Join(p.Root, path)
}
raw, err := os.ReadFile(path)
if err != nil {
if os.IsNotExist(err) {
return nil, unavailableAutogenManifest(fmt.Errorf("manifest file %s not found", path))
}
return nil, fmt.Errorf("read autogen manifest file %s: %w", path, err)
}
var manifest autogenManifest
if err := json.Unmarshal(raw, &manifest); err != nil {
return nil, fmt.Errorf("parse autogen manifest file %s: %w", path, err)
}
if manifest.ID != "" && manifest.ID != consumer.Producer {
return nil, fmt.Errorf("autogen manifest file %s declared id %q, expected %q", path, manifest.ID, consumer.Producer)
}
if progress != nil {
progress(fmt.Sprintf("Reading local autogen manifest for %s from %s...", consumer.ID, path))
}
return &manifest, nil
}
func resolveAutogenLocalOverrideRoot(p *project.Project, consumer project.AutogenConsumerConfig) (string, error) {
root := strings.TrimSpace(consumer.LocalOverrideRoot)
if root != "" {