2026-07-04 00:59:32 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
2026-07-17 04:53:09 +00:00
|
|
|
dndregister "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/register"
|
|
|
|
|
genericregister "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/register"
|
|
|
|
|
seriatimregister "gitea.maximumdirect.net/eric/notarius/internal/modules/seriatim/register"
|
2026-07-04 00:59:32 +00:00
|
|
|
)
|
|
|
|
|
|
2026-07-17 04:53:09 +00:00
|
|
|
type productionComponents struct {
|
|
|
|
|
registries pipeline.Registries
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newProductionComponents() (productionComponents, error) {
|
2026-07-04 00:59:32 +00:00
|
|
|
registries := pipeline.Registries{
|
2026-07-27 18:04:12 +00:00
|
|
|
Inputs: pipeline.NewInputAdapterRegistry(),
|
|
|
|
|
Chunkers: pipeline.NewChunkerRegistry(),
|
|
|
|
|
ArtifactCodecs: pipeline.NewArtifactCodecRegistry(),
|
|
|
|
|
ArtifactEvidence: pipeline.NewArtifactEvidenceRegistry(),
|
|
|
|
|
Extractors: pipeline.NewExtractorRegistry(),
|
|
|
|
|
Mergers: pipeline.NewMergerRegistry(),
|
|
|
|
|
Normalizers: pipeline.NewNormalizerRegistry(),
|
|
|
|
|
Validators: pipeline.NewValidatorRegistry(),
|
|
|
|
|
ValidatorChains: pipeline.NewValidatorChainRegistry(),
|
|
|
|
|
Outputs: pipeline.NewOutputEncoderRegistry(),
|
2026-07-04 00:59:32 +00:00
|
|
|
}
|
2026-07-17 04:53:09 +00:00
|
|
|
registrars := []struct {
|
2026-07-07 21:43:32 +00:00
|
|
|
name string
|
2026-11-22 01:35:23 +00:00
|
|
|
register func(pipeline.Registries) error
|
2026-07-07 21:43:32 +00:00
|
|
|
}{
|
2026-07-17 04:53:09 +00:00
|
|
|
{name: "generic", register: genericregister.Register},
|
|
|
|
|
{name: "seriatim", register: seriatimregister.Register},
|
|
|
|
|
{name: "dnd", register: dndregister.Register},
|
|
|
|
|
}
|
|
|
|
|
for _, registrar := range registrars {
|
2026-11-22 01:35:23 +00:00
|
|
|
if err := registrar.register(registries); err != nil {
|
2026-07-17 04:53:09 +00:00
|
|
|
return productionComponents{}, fmt.Errorf("register %s module family: %w", registrar.name, err)
|
2026-07-07 21:43:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-11-22 03:51:08 +00:00
|
|
|
return productionComponents{registries: registries}, nil
|
2026-07-07 21:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-17 04:53:09 +00:00
|
|
|
func productionRegistries() (pipeline.Registries, error) {
|
|
|
|
|
components, err := newProductionComponents()
|
|
|
|
|
return components.registries, err
|
2026-07-07 21:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-04 00:59:32 +00:00
|
|
|
func productionCatalog() (pipeline.ModuleCatalog, error) {
|
|
|
|
|
registries, err := productionRegistries()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return pipeline.ModuleCatalog{}, err
|
|
|
|
|
}
|
|
|
|
|
return catalogFromRegistries(registries), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func effectiveCatalog(opts Options) (pipeline.ModuleCatalog, error) {
|
|
|
|
|
if !isEmptyCatalog(opts.Catalog) {
|
|
|
|
|
return opts.Catalog, nil
|
|
|
|
|
}
|
|
|
|
|
if !isEmptyRegistries(opts.Registries) {
|
|
|
|
|
return catalogFromRegistries(opts.Registries), nil
|
|
|
|
|
}
|
|
|
|
|
return productionCatalog()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func effectiveRegistries(opts Options) (pipeline.Registries, error) {
|
|
|
|
|
if !isEmptyRegistries(opts.Registries) {
|
|
|
|
|
return opts.Registries, nil
|
|
|
|
|
}
|
|
|
|
|
if !isEmptyCatalog(opts.Catalog) {
|
|
|
|
|
return registriesFromCatalog(opts.Catalog), nil
|
|
|
|
|
}
|
|
|
|
|
return productionRegistries()
|
|
|
|
|
}
|