Retain selected glossary instructions

This commit is contained in:
2026-11-26 18:14:27 +00:00
parent d2c4c63580
commit b1cde637a2
5 changed files with 51 additions and 2 deletions

View File

@@ -33,7 +33,8 @@ type Config struct {
}
type GlossaryCollection struct {
Entries []GlossaryEntry `yaml:"entries"`
Instruction string `yaml:"instruction"`
Entries []GlossaryEntry `yaml:"entries"`
}
type GlossaryEntry struct {
ID string `yaml:"id"`
@@ -106,11 +107,18 @@ func defaults() Config {
}
}
// GlossaryEntryIdentity identifies entries beneath a collections mapping.
func GlossaryEntryIdentity(prefix ck.SequenceSelector) ck.SequenceIdentity {
selector := append(ck.SequenceSelector(nil), prefix...)
selector = append(selector, ck.SequenceAnyMappingKey(), ck.SequenceLiteralKey("entries"))
return ck.SequenceIdentityMatching(selector, "id")
}
// Definition describes the application settings independently of their sources.
func Definition() ck.Definition[Config] {
return ck.Definition[Config]{
Defaults: defaults,
SequenceIdentities: []ck.SequenceIdentity{ck.SequenceIdentityMatching(ck.SequenceSelector{ck.SequenceLiteralKey("glossary_collections"), ck.SequenceAnyMappingKey(), ck.SequenceLiteralKey("entries")}, "id")},
SequenceIdentities: []ck.SequenceIdentity{GlossaryEntryIdentity(ck.SequenceSelector{ck.SequenceLiteralKey("glossary_collections")})},
Version: &ck.VersionRule{Path: ck.Keys("version"), Check: func(version ck.Version, v *ck.Validation) error {
if version.Present && (version.Null || version.Text != "3") {
v.Error(ck.Keys("version"), "use application configuration version 3; see docs/migrations/v3.md")