From a0c7e55f92c74f1d7ee3ea7e3d47a59e65c44ada Mon Sep 17 00:00:00 2001 From: William Perreault Date: Mon, 9 Sep 2024 20:43:35 -0400 Subject: [PATCH] Add assembly preprocessing (#26) --- pkg/specter/assembly.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/specter/assembly.go b/pkg/specter/assembly.go index a8a9103..330d573 100644 --- a/pkg/specter/assembly.go +++ b/pkg/specter/assembly.go @@ -19,12 +19,14 @@ type PipelineBuilder struct { SourceLoaders []SourceLoader UnitLoaders []UnitLoader + UnitPreprocessors []UnitPreprocessor UnitProcessors []UnitProcessor ArtifactProcessors []ArtifactProcessor ArtifactRegistry ArtifactRegistry SourceLoadingStageHooks SourceLoadingStageHooks UnitLoadingStageHooks UnitLoadingStageHooks + UnitPreprocessingStageHooks UnitPreprocessingStageHooks UnitProcessingStageHooks UnitProcessingStageHooks ArtifactProcessingStageHooks ArtifactProcessingStageHooks } @@ -54,6 +56,12 @@ func (b PipelineBuilder) WithUnitLoaders(loaders ...UnitLoader) PipelineBuilder return b } +// WithUnitPreprocessors configures the UnitPreprocessors of a Pipeline instance. +func (b PipelineBuilder) WithUnitPreprocessors(preprocessors ...UnitPreprocessor) PipelineBuilder { + b.UnitPreprocessors = preprocessors + return b +} + // WithUnitProcessors configures the UnitProcess of a Pipeline instance. func (b PipelineBuilder) WithUnitProcessors(processors ...UnitProcessor) PipelineBuilder { b.UnitProcessors = processors @@ -82,6 +90,11 @@ func (b PipelineBuilder) WithUnitLoadingStageHooks(h UnitLoadingStageHooks) Pipe return b } +func (b PipelineBuilder) WithUnitPreprocessingStageHooks(hooks UnitPreprocessingStageHooks) PipelineBuilder { + b.UnitPreprocessingStageHooks = hooks + return b +} + func (b PipelineBuilder) WithUnitProcessingStageHooks(h UnitProcessingStageHooks) PipelineBuilder { b.UnitProcessingStageHooks = h return b @@ -99,6 +112,10 @@ func (b PipelineBuilder) Build() Pipeline { SourceLoaders: b.SourceLoaders, Hooks: b.SourceLoadingStageHooks, }, + UnitPreprocessingStage: unitPreprocessingStage{ + Preprocessors: b.UnitPreprocessors, + Hooks: b.UnitPreprocessingStageHooks, + }, UnitLoadingStage: unitLoadingStage{ Loaders: b.UnitLoaders, Hooks: b.UnitLoadingStageHooks,