Complete shared glossary validation and acceptance checks
This commit is contained in:
@@ -3,7 +3,6 @@ package sharedglossary
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
|
||||
ck "go.maximumdirect.net/configkit"
|
||||
@@ -30,8 +29,15 @@ func Load(ctx context.Context, inputs []ck.Input) (*ck.Result[map[string]any], e
|
||||
main := inputs[len(inputs)-1]
|
||||
main.Imports = true
|
||||
result, err := ck.LoadLayered(main, ck.LayeredOptions[map[string]any]{
|
||||
Definition: ck.Definition[map[string]any]{SequenceIdentities: []ck.SequenceIdentity{config.GlossaryEntryIdentity(ck.SequenceSelector{ck.SequenceLiteralKey("collections")})}},
|
||||
Underlays: underlays,
|
||||
Definition: ck.Definition[map[string]any]{
|
||||
SequenceIdentities: []ck.SequenceIdentity{config.GlossaryEntryIdentity(ck.SequenceSelector{ck.SequenceLiteralKey("collections")})},
|
||||
Validate: func(document *map[string]any, validation *ck.Validation) {
|
||||
if err := validator.Validate(*document, "input"); err != nil {
|
||||
validation.Error(ck.Keys(), err.Error())
|
||||
}
|
||||
},
|
||||
},
|
||||
Underlays: underlays,
|
||||
})
|
||||
if canceled := ctx.Err(); canceled != nil {
|
||||
return nil, errors.Join(err, canceled)
|
||||
@@ -39,14 +45,5 @@ func Load(ctx context.Context, inputs []ck.Input) (*ck.Result[map[string]any], e
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var sources []string
|
||||
for _, source := range result.Sources() {
|
||||
if source.Path != "" {
|
||||
sources = append(sources, source.Path)
|
||||
}
|
||||
}
|
||||
if err := validator.Validate(result.Config, strings.Join(sources, ", ")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user