Derive artifact catalogs from the selected party without changing configuration
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -27,15 +26,20 @@ type EffectiveArtifactRecord struct {
|
||||
// EffectiveArtifactCatalog returns the deterministic concrete artifact catalog
|
||||
// consumed by runtime planning.
|
||||
func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]EffectiveArtifactRecord, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("pipeline config is required")
|
||||
catalog, err := DeriveArtifactCatalog(cfg, party)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cfg.Scriptorium == nil || len(cfg.Scriptorium.Artifacts) == 0 {
|
||||
return []EffectiveArtifactRecord{}, nil
|
||||
return catalog.Records, nil
|
||||
}
|
||||
|
||||
func concreteArtifactRecords(cfg *PipelineConfig, catalog *ArtifactCatalog, party ResolvedParty) []EffectiveArtifactRecord {
|
||||
if len(catalog.Artifacts) == 0 {
|
||||
return []EffectiveArtifactRecord{}
|
||||
}
|
||||
|
||||
keys := make([]string, 0, len(cfg.Scriptorium.Artifacts))
|
||||
for key := range cfg.Scriptorium.Artifacts {
|
||||
keys := make([]string, 0, len(catalog.Artifacts))
|
||||
for key := range catalog.Artifacts {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
@@ -43,7 +47,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
||||
pathsByID := pipelineSourcePaths(cfg)
|
||||
partySources := partyCharacterSourceLookup(party)
|
||||
for _, key := range keys {
|
||||
artifact := cfg.Scriptorium.Artifacts[key]
|
||||
artifact := catalog.Artifacts[key]
|
||||
record := EffectiveArtifactRecord{
|
||||
Key: key,
|
||||
SourceID: artifactpolicy.ConfiguredSourceID(key),
|
||||
@@ -51,11 +55,11 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
||||
OutputPath: artifact.OutputPath,
|
||||
Dependencies: append([]string(nil), artifact.DependsOn...),
|
||||
}
|
||||
if member, ok := cfg.familyCatalog.Members[key]; ok {
|
||||
record.DefinitionSources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
|
||||
if member, ok := catalog.Families.Members[key]; ok {
|
||||
record.DefinitionSources = append([]string(nil), catalog.Families.Families[member.Family].Sources...)
|
||||
record.FamilyKey = member.Family
|
||||
record.CharacterID = member.CharacterID
|
||||
record.FamilySources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
|
||||
record.FamilySources = append([]string(nil), catalog.Families.Families[member.Family].Sources...)
|
||||
record.PartySource = strings.Join(partySources(member.CharacterID), ",")
|
||||
} else {
|
||||
record.DefinitionSources = declarationDefinitionSourcesWithIndex(cfg, configkit.Keys("scriptorium", "artifacts", key), pathsByID)
|
||||
@@ -63,7 +67,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
||||
record.Dependencies = nonEmptySortedStrings(record.Dependencies)
|
||||
records = append(records, record)
|
||||
}
|
||||
return records, nil
|
||||
return records
|
||||
}
|
||||
|
||||
// partyCharacterSourceLookup owns a single inspection's detached native evidence.
|
||||
|
||||
Reference in New Issue
Block a user