Complete artifact provenance reporting
This commit is contained in:
@@ -50,7 +50,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
||||
Dependencies: append([]string(nil), artifact.DependsOn...),
|
||||
}
|
||||
if member, ok := cfg.familyCatalog.Members[key]; ok {
|
||||
record.DefinitionSources = nonEmptySortedStrings([]string{member.Source})
|
||||
record.DefinitionSources = artifactFamilyDefinitionSources(cfg, member.Family)
|
||||
record.FamilyKey = member.Family
|
||||
record.CharacterID = member.CharacterID
|
||||
record.FamilySource = member.Source
|
||||
@@ -65,7 +65,21 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
||||
}
|
||||
|
||||
func artifactDefinitionSources(cfg *PipelineConfig, key string) []string {
|
||||
if cfg.resolution == nil {
|
||||
return declarationDefinitionSources(cfg,
|
||||
configkit.Keys("scriptorium", "artifacts", key),
|
||||
"scriptorium.artifacts."+key,
|
||||
)
|
||||
}
|
||||
|
||||
func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string {
|
||||
return declarationDefinitionSources(cfg,
|
||||
configkit.Keys("scriptorium", "artifact_families", key),
|
||||
"scriptorium.artifact_families."+key,
|
||||
)
|
||||
}
|
||||
|
||||
func declarationDefinitionSources(cfg *PipelineConfig, declaration configkit.Path, prefix string) []string {
|
||||
if cfg == nil || cfg.resolution == nil {
|
||||
return nil
|
||||
}
|
||||
pathsByID := make(map[string]string, len(cfg.resolution.configkitSources))
|
||||
@@ -78,7 +92,6 @@ func artifactDefinitionSources(cfg *PipelineConfig, key string) []string {
|
||||
}
|
||||
|
||||
seen := map[string]struct{}{}
|
||||
declaration := configkit.Keys("scriptorium", "artifacts", key)
|
||||
for _, change := range cfg.resolution.configkitMetadata.History(declaration) {
|
||||
if change.Origin.Layer != configkit.LayerBase && change.Origin.Layer != configkit.LayerProfile {
|
||||
continue
|
||||
@@ -92,7 +105,6 @@ func artifactDefinitionSources(cfg *PipelineConfig, key string) []string {
|
||||
}
|
||||
}
|
||||
if len(seen) == 0 {
|
||||
prefix := "scriptorium.artifacts." + key
|
||||
for _, ownership := range cfg.resolution.ownership {
|
||||
if ownership.path != prefix && !strings.HasPrefix(ownership.path, prefix+".") {
|
||||
continue
|
||||
|
||||
@@ -227,9 +227,39 @@ func effectivePipelineOwners(cfg *PipelineConfig) map[string][]string {
|
||||
for _, ownership := range cfg.resolution.ownership {
|
||||
owners[ownership.path] = append([]string(nil), ownership.sources...)
|
||||
}
|
||||
if cfg.Scriptorium != nil {
|
||||
for key, artifact := range cfg.Scriptorium.Artifacts {
|
||||
paths := artifactDependencyOwnershipPaths(key, artifact)
|
||||
if sources := sourcesForPipelinePaths(owners, paths); len(sources) != 0 {
|
||||
sort.Strings(sources)
|
||||
owners["scriptorium.artifacts."+key+".depends_on"] = sources
|
||||
}
|
||||
}
|
||||
}
|
||||
return owners
|
||||
}
|
||||
|
||||
func artifactDependencyOwnershipPaths(artifactKey string, artifact ScriptoriumArtifactConfig) []string {
|
||||
var paths []string
|
||||
for _, dependency := range artifact.DependsOn {
|
||||
for _, origin := range artifact.dependencyOrigins[dependency] {
|
||||
prefix := "scriptorium.artifacts." + artifactKey
|
||||
if origin.family != "" {
|
||||
prefix = "scriptorium.artifact_families." + origin.family
|
||||
}
|
||||
switch {
|
||||
case origin.inputName != "":
|
||||
paths = append(paths, prefix+".inputs."+origin.inputName+".source")
|
||||
case origin.family != "":
|
||||
paths = append(paths, prefix+".member_dependencies")
|
||||
default:
|
||||
paths = append(paths, prefix+".depends_on")
|
||||
}
|
||||
}
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
||||
func generatedArtifactFamilyForPath(path string, families ArtifactFamilyCatalog) (string, bool) {
|
||||
const prefix = "scriptorium.artifacts."
|
||||
if !strings.HasPrefix(path, prefix) {
|
||||
@@ -269,7 +299,7 @@ func generatedArtifactSources(path, familyKey string, families ArtifactFamilyCat
|
||||
case suffix == "output_path":
|
||||
candidates = []string{familyPrefix + "output_path_pattern"}
|
||||
case suffix == "depends_on":
|
||||
candidates = []string{familyPrefix + "depends_on", familyPrefix + "member_dependencies"}
|
||||
candidates = []string{path, familyPrefix + "depends_on", familyPrefix + "member_dependencies"}
|
||||
case strings.HasPrefix(suffix, "vars."):
|
||||
variable := strings.TrimPrefix(suffix, "vars.")
|
||||
candidates = []string{familyPrefix + "vars." + variable, familyPrefix + "member_vars." + variable}
|
||||
|
||||
Reference in New Issue
Block a user