Avoid repeated glossary selection and membership work
This commit is contained in:
@@ -4,10 +4,10 @@ package preflight
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/glossary"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
|
||||
)
|
||||
@@ -105,7 +105,13 @@ func CheckReadiness(ctx context.Context, cfg *config.Config, inspectProfile func
|
||||
return fmt.Sprintf("stage %d (%s)", index+1, item.Module)
|
||||
}
|
||||
for index, item := range cfg.Pipeline.Stages {
|
||||
if item.Module == modulecatalog.KeyGlossary && len(glossary.Select(cfg.GlossaryCollections, item.Glossaries)) == 0 {
|
||||
if item.Module != modulecatalog.KeyGlossary {
|
||||
continue
|
||||
}
|
||||
hasEntries := slices.ContainsFunc(item.Glossaries, func(name string) bool {
|
||||
return len(cfg.GlossaryCollections[name].Entries) > 0
|
||||
})
|
||||
if !hasEntries {
|
||||
return fmt.Errorf("%s has no glossary entries in selected collections %q", label(index, item), item.Glossaries)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user