Skip to content

Commit

Permalink
Fix unitProcessingStage's default implementation doubling units (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwillp authored Sep 10, 2024
1 parent a0c7e55 commit 9df068f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
10 changes: 1 addition & 9 deletions pkg/specter/assembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ type PipelineBuilder struct {

// NewPipeline creates a new instance of a *Pipeline using the provided options.
func NewPipeline() PipelineBuilder {
return PipelineBuilder{
pipeline: &DefaultPipeline{
TimeProvider: CurrentTimeProvider,
SourceLoadingStage: sourceLoadingStage{},
UnitLoadingStage: unitLoadingStage{},
UnitProcessingStage: unitProcessingStage{},
ArtifactProcessingStage: artifactProcessingStage{},
},
}
return PipelineBuilder{}
}

// WithSourceLoaders configures the SourceLoader of a Pipeline instance.
Expand Down
14 changes: 6 additions & 8 deletions pkg/specter/pipelinedefault.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,36 @@ func (p DefaultPipeline) Run(ctx context.Context, runMode RunMode, sourceLocatio
return result, err
}

func (p DefaultPipeline) run(pctx *PipelineContext, sourceLocations []string, runMode RunMode) error {
if err := p.runSourceLoadingStage(pctx, sourceLocations); err != nil {
func (p DefaultPipeline) run(ctx *PipelineContext, sourceLocations []string, runMode RunMode) error {
if err := p.runSourceLoadingStage(ctx, sourceLocations); err != nil {
return err
}
if runMode == StopAfterSourceLoadingStage {
return nil
}

if err := p.runUnitLoadingStage(pctx); err != nil {
if err := p.runUnitLoadingStage(ctx); err != nil {
return err
}
if runMode == StopAfterUnitLoadingStage {
return nil
}

if err := p.runUnitPreprocessingStage(pctx); err != nil {
if err := p.runUnitPreprocessingStage(ctx); err != nil {
return err
}
if runMode == StopAfterPreprocessingStage {
return nil
}

if err := p.runUnitProcessingStage(pctx); err != nil {
if err := p.runUnitProcessingStage(ctx); err != nil {
return err
}
if runMode == StopAfterUnitProcessingStage {
return nil
}

if err := p.runArtifactProcessingStage(pctx); err != nil {
if err := p.runArtifactProcessingStage(ctx); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -365,8 +365,6 @@ func (s unitPreprocessingStage) run(ctx PipelineContext, units []Unit) ([]Unit,
if err != nil {
return nil, fmt.Errorf("preprocessor %q returned an error: %w", p.Name(), err)
}

units = append(ctx.Units, units...)
ctx.Units = units

if err := s.Hooks.AfterPreprocessor(ctx, p.Name()); err != nil {
Expand Down

0 comments on commit 9df068f

Please sign in to comment.