Configure flat outputs and native Notarius controls
This commit is contained in:
69
internal/config/product_destinations.go
Normal file
69
internal/config/product_destinations.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
||||
)
|
||||
|
||||
// validateProductDestinations compares resolved destinations after family expansion.
|
||||
// The same configured paths are consumed by planning and stage execution.
|
||||
func validateProductDestinations(cfg *Config, catalog *ArtifactCatalog) error {
|
||||
root, err := filepath.Abs(filepath.Join(cfg.Pipeline.Workspace.Root, PathWorkDirSegment, cfg.Session.Campaign, cfg.Session.SessionID))
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve session output root: %w", err)
|
||||
}
|
||||
owners := make(map[string]string)
|
||||
add := func(producer, category, configured string) error {
|
||||
configured = strings.TrimSpace(configured)
|
||||
if configured == "" {
|
||||
return nil
|
||||
}
|
||||
destination := configured
|
||||
if !filepath.IsAbs(destination) {
|
||||
destination = filepath.Join(root, destination)
|
||||
}
|
||||
destination = filepath.Clean(destination)
|
||||
if filepath.Dir(destination) != filepath.Join(root, category) {
|
||||
return fmt.Errorf("%s destination %q must be directly under %s/", producer, configured, category)
|
||||
}
|
||||
if previous, exists := owners[destination]; exists {
|
||||
return fmt.Errorf("%s and %s both produce %q", previous, producer, destination)
|
||||
}
|
||||
owners[destination] = producer
|
||||
return nil
|
||||
}
|
||||
for _, spec := range artifactmodel.RuntimeTranscriptArtifacts() {
|
||||
path := spec.CanonicalRelPath
|
||||
if spec.SourceID == artifactmodel.SourceTranscriptFinal && cfg.Pipeline.Normalize != nil {
|
||||
path = cfg.Pipeline.Normalize.OutputPath
|
||||
}
|
||||
if spec.SourceID == artifactmodel.SourceTranscriptFinalTrimmed && cfg.Pipeline.Trim != nil {
|
||||
path = cfg.Pipeline.Trim.OutputPath
|
||||
}
|
||||
if err := add(spec.SourceID, "transcripts", path); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if cfg.Pipeline.Trim != nil {
|
||||
if err := add("pipeline.trim.bounds", "artifacts", cfg.Pipeline.Trim.Bounds.OutputPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if cfg.Pipeline.Notarius != nil && cfg.Pipeline.Notarius.Enabled {
|
||||
for _, key := range sortedStringKeys(cfg.Pipeline.Notarius.Outputs) {
|
||||
path := filepath.Join("artifacts", ExtractionFilename(key, cfg.Pipeline.Notarius.Outputs[key]))
|
||||
if err := add("pipeline.notarius.outputs."+key, "artifacts", path); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, key := range sortedStringKeys(catalog.Artifacts) {
|
||||
if err := add("pipeline.scriptorium.artifacts."+key, "artifacts", catalog.Artifacts[key].OutputPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user