Rename selected configuration profiles to overlays

This commit is contained in:
2026-09-23 18:27:29 +00:00
parent 66e080ed34
commit ae91f57bbe
32 changed files with 306 additions and 283 deletions

View File

@@ -21,13 +21,13 @@ type explanationConcurrency struct {
} `yaml:"transcription"`
}
func TestExplainShowsDefaultBaseAndEffectiveProfileValue(t *testing.T) {
func TestExplainShowsDefaultBaseAndEffectiveOverlayValue(t *testing.T) {
directory := t.TempDir()
mainPath := writeImportFile(t, directory, "config.yml", "configkit:\n imports: [{path: transcription.yml}]\n")
writeImportFile(t, directory, "transcription.yml", "transcription:\n concurrency: 8\n")
writeImportFile(t, directory, filepath.Join("profiles", "testing.yml"), "transcription:\n concurrency: 1\n")
writeImportFile(t, directory, filepath.Join("overlays", "testing.yml"), "transcription:\n concurrency: 1\n")
result, err := testLoad[explanationConcurrency](File(mainPath), Options[explanationConcurrency]{
Imports: true, Profile: "testing",
Imports: true, Overlay: "testing",
Definition: Definition[explanationConcurrency]{Defaults: func() explanationConcurrency {
value := explanationConcurrency{}
value.Transcription.Concurrency = 4
@@ -44,7 +44,7 @@ func TestExplainShowsDefaultBaseAndEffectiveProfileValue(t *testing.T) {
if got := explanationValues(explanation); !reflect.DeepEqual(got, []string{"4\n", "8\n", "1\n"}) {
t.Fatalf("history values = %#v", got)
}
if explanation.Effective.YAML != "1\n" || explanation.Origin.Layer != LayerProfile ||
if explanation.Effective.YAML != "1\n" || explanation.Origin.Layer != LayerOverlay ||
len(explanation.Origin.Locations) != 1 || explanation.Origin.Locations[0].SourceID != "source-3" ||
explanation.Origin.Locations[0].Line != 2 {
t.Fatalf("effective explanation = %#v", explanation)
@@ -70,18 +70,18 @@ func TestExplainReplaysCLIResolutionContainersAndSafeHistoricalValues(t *testing
directory := t.TempDir()
mainPath := writeImportFile(t, directory, "config.yml", `concurrency: 8
equal: same
limit: wrong-before-profile
limit: wrong-before-overlay
items: [base, removed]
labels: {base: retained}
dynamic: {retired: HISTORICAL_EXPLAIN_CANARY, public: visible}
credential: APP_SECRET
classified: APP_SECRET
`)
writeImportFile(t, directory, filepath.Join("profiles", "testing.yml"), `concurrency: 1
writeImportFile(t, directory, filepath.Join("overlays", "testing.yml"), `concurrency: 1
equal: same
limit: 7
items: [profile]
labels: {profile: retained}
items: [overlay]
labels: {overlay: retained}
dynamic: selected
`)
result, err := testLoadWithSecretLookup(File(mainPath), func(name string) (string, bool) {
@@ -90,7 +90,7 @@ dynamic: selected
}
return "RESOLVED_EXPLAIN_CANARY", true
}, Options[explanationConfig]{
Profile: "testing",
Overlay: "testing",
Overrides: []Override{
{Path: Keys("concurrency"), Value: 2, Flag: "--concurrency"},
{Path: Keys("equal"), Value: "same", Flag: "--equal"},
@@ -130,7 +130,7 @@ dynamic: selected
if got := explanationValues(concurrency); !reflect.DeepEqual(got, []string{"4\n", "8\n", "1\n", "2\n", "3\n"}) {
t.Fatalf("concurrency history = %#v", got)
}
if got := historyValueLayers(concurrency); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerBase, LayerProfile, LayerCLI, LayerResolution}) {
if got := historyValueLayers(concurrency); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerBase, LayerOverlay, LayerCLI, LayerResolution}) {
t.Fatalf("concurrency layers = %#v", got)
}
if concurrency.History[4].Before.YAML != "2\n" || concurrency.History[4].Reasons[0] != "normalized\nconcurrency" ||
@@ -149,7 +149,7 @@ dynamic: selected
}
limit, _ := result.Explain(Keys("limit"))
if got := explanationValues(limit); !reflect.DeepEqual(got, []string{"0\n", "wrong-before-profile\n", "7\n"}) {
if got := explanationValues(limit); !reflect.DeepEqual(got, []string{"0\n", "wrong-before-overlay\n", "7\n"}) {
t.Fatalf("overridden invalid input was not retained: %#v", got)
}
removed, ok := result.Explain(Keys("dynamic", "retired"))
@@ -182,7 +182,7 @@ dynamic: selected
}
labels, _ := result.Explain(Keys("labels"))
if len(labels.History) != 4 || !strings.Contains(labels.Effective.YAML, "default: retained") ||
!strings.Contains(labels.Effective.YAML, "profile: retained") || !strings.Contains(labels.Effective.YAML, "cli: retained") {
!strings.Contains(labels.Effective.YAML, "overlay: retained") || !strings.Contains(labels.Effective.YAML, "cli: retained") {
t.Fatalf("composite mapping history = %#v", labels)
}
if labels.Origin.Layer != LayerCLI || len(labels.Origin.Locations) != 3 {
@@ -258,7 +258,7 @@ dynamic: selected
var invalidInput bytes.Buffer
if err := result.WriteExplanation(&invalidInput, Keys("limit")); err != nil ||
!strings.Contains(invalidInput.String(), "policy-validated input") ||
strings.Contains(invalidInput.String(), "wrong-before-profile\n source: layer=\"base\"\n before (canonical typed)") {
strings.Contains(invalidInput.String(), "wrong-before-overlay\n source: layer=\"base\"\n before (canonical typed)") {
t.Fatalf("historical representation rendering = %v\n%s", err, invalidInput.String())
}
}
@@ -340,8 +340,8 @@ func TestExplanationReconcilesDefaultsAfterInputReplacement(t *testing.T) {
if cli {
opts.Overrides = []Override{{Path: Keys("m"), Value: map[string]any{"b": 2}, Flag: "--m"}}
} else {
writeImportFile(t, root, "profiles/p.yml", "m: {b: 2}\n")
opts.Profile = "p"
writeImportFile(t, root, "overlays/p.yml", "m: {b: 2}\n")
opts.Overlay = "p"
}
result, err := testLoad(File(main), opts)
if err != nil {