From 5751870b0fef5cf624a94cbf6edbd0cc238acb46 Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Wed, 26 Jun 2024 16:12:02 +0400 Subject: [PATCH] fix: do not reuse initializer Signed-off-by: knqyf263 --- pkg/commands/artifact/run.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/commands/artifact/run.go b/pkg/commands/artifact/run.go index 7ca4fc40032a..db73cf58b391 100644 --- a/pkg/commands/artifact/run.go +++ b/pkg/commands/artifact/run.go @@ -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) } @@ -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) }