Skip to content

Commit

Permalink
fix: do not reuse initializer
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed Jun 26, 2024
1 parent 4641984 commit 5751870
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/commands/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ func (r *runner) ScanVM(ctx context.Context, opts flag.Options) (types.Report, e
}

func (r *runner) scanArtifact(ctx context.Context, opts flag.Options, initializeScanner InitializeScanner) (types.Report, error) {
if r.initializeScanner == nil {
r.initializeScanner = initializeScanner
if r.initializeScanner != nil {
initializeScanner = r.initializeScanner
}
report, err := r.scan(ctx, opts)
report, err := r.scan(ctx, opts, initializeScanner)
if err != nil {
return types.Report{}, xerrors.Errorf("scan error: %w", err)
}
Expand Down Expand Up @@ -614,12 +614,12 @@ func (r *runner) initScannerConfig(opts flag.Options) (ScannerConfig, types.Scan
}, scanOptions, nil
}

func (r *runner) scan(ctx context.Context, opts flag.Options) (types.Report, error) {
func (r *runner) scan(ctx context.Context, opts flag.Options, initializeScanner InitializeScanner) (types.Report, error) {
scannerConfig, scanOptions, err := r.initScannerConfig(opts)
if err != nil {
return types.Report{}, err
}
s, cleanup, err := r.initializeScanner(ctx, scannerConfig)
s, cleanup, err := initializeScanner(ctx, scannerConfig)
if err != nil {
return types.Report{}, xerrors.Errorf("unable to initialize a scanner: %w", err)
}
Expand Down

0 comments on commit 5751870

Please sign in to comment.