Report effective resource contributors without superseded definitions
This commit is contained in:
@@ -273,9 +273,17 @@ func effectivePipelineOwners(cfg *PipelineConfig) (map[string][]string, error) {
|
||||
sources = ownershipSources(info.Origin, pathsByID)
|
||||
if info.Origin.Layer == configkit.LayerResolution {
|
||||
for _, change := range cfg.resolution.configkitMetadata.History(configkit.Keys(value.segments...)) {
|
||||
if change.Origin.Layer == configkit.LayerMain || change.Origin.Layer == configkit.LayerOverlay {
|
||||
sources = append(sources, ownershipSources(change.Origin, pathsByID)...)
|
||||
if change.Origin.Layer != configkit.LayerResolution {
|
||||
continue
|
||||
}
|
||||
// Native Previous evidence identifies the input immediately before
|
||||
// resolution, including composite and inherited origins.
|
||||
for _, previous := range change.Previous {
|
||||
if previous.Layer == configkit.LayerMain || previous.Layer == configkit.LayerOverlay {
|
||||
sources = append(sources, ownershipSources(previous, pathsByID)...)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
sources = nonEmptySortedStrings(sources)
|
||||
}
|
||||
|
||||
42
internal/config/effective_resource_sources_test.go
Normal file
42
internal/config/effective_resource_sources_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEffectiveResourceSourcesExcludeSupersededDefinitions(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", "config:\n imports:\n - path: shared.yml\nnotarius:\n extends: audita\n")
|
||||
writePipelineFixture(t, dir, "shared.yml", "audita: {config_path: old.yml}\n")
|
||||
overlayPath := writePipelineFixture(t, dir, "overlays/testing.yml", "audita: {config_path: replacement.yml}\n")
|
||||
overlay := "testing"
|
||||
cfg, err := LoadPipelineWithOptions(root, PipelineLoadOptions{Overlay: &overlay})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
records, err := EffectivePipelineSources(cfg, ResolvedParty{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{"audita.config_path", "notarius.config_path"} {
|
||||
foundOverlay, foundResolution := false, false
|
||||
for _, record := range records {
|
||||
if record.Path != path {
|
||||
continue
|
||||
}
|
||||
if record.Role == "overlay" && record.Source == overlayPath {
|
||||
foundOverlay = true
|
||||
}
|
||||
if record.Role == "resolution" {
|
||||
foundResolution = true
|
||||
}
|
||||
if record.Source == filepath.Join(dir, "shared.yml") {
|
||||
t.Fatalf("superseded source for %s: %#v", path, record)
|
||||
}
|
||||
}
|
||||
if !foundOverlay || !foundResolution {
|
||||
t.Fatalf("missing effective evidence for %s: %#v", path, records)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user