diff --git a/explorer/scan/local_scanner.go b/explorer/scan/local_scanner.go index deee3f3854..eb3a01c27a 100644 --- a/explorer/scan/local_scanner.go +++ b/explorer/scan/local_scanner.go @@ -221,6 +221,8 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up } }() + // plan scan jobs + reporter := NewAggregateReporter() if job.Bundle == nil && upstream != nil && upstream.Creds != nil { client, err := upstream.InitClient() if err != nil { @@ -237,10 +239,9 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up return nil, err } job.Bundle = bundle + reporter.AddBundle(bundle) } - // plan scan jobs - reporter := NewAggregateReporter() // if we had asset errors we want to place them into the reporter for i := range discoveredAssets.Errors { reporter.AddScanError(discoveredAssets.Errors[i].Asset, discoveredAssets.Errors[i].Err) @@ -461,6 +462,11 @@ func (s *localAssetScanner) prepareAsset() error { if err := s.ensureBundle(); err != nil { return err } + + // add asset bundle to the reporter + if s.job.Reporter != nil && s.job.Bundle != nil { + s.job.Reporter.AddBundle(s.job.Bundle) + } } if s.job.Bundle == nil { @@ -653,8 +659,7 @@ func (s *localAssetScanner) runQueryPack() (*AssetReport, error) { } ar := &AssetReport{ - Mrn: s.job.Asset.Mrn, - // Bundle: assetBundle, + Mrn: s.job.Asset.Mrn, Resolved: resolvedPack, } diff --git a/explorer/scan/reporter.go b/explorer/scan/reporter.go index ff90e38222..a9244ddc1c 100644 --- a/explorer/scan/reporter.go +++ b/explorer/scan/reporter.go @@ -11,12 +11,12 @@ import ( type Reporter interface { AddReport(asset *inventory.Asset, results *AssetReport) + AddBundle(bundle *explorer.Bundle) AddScanError(asset *inventory.Asset, err error) } type AssetReport struct { Mrn string - Bundle *explorer.Bundle Report *explorer.Report Resolved *explorer.ResolvedPack } @@ -42,7 +42,10 @@ func (r *AggregateReporter) AddReport(asset *inventory.Asset, results *AssetRepo r.assets[asset.Mrn] = &explorer.Asset{Name: asset.Name, Mrn: asset.Mrn} r.assetReports[asset.Mrn] = results.Report r.resolved[asset.Mrn] = results.Resolved - r.bundle = results.Bundle +} + +func (r *AggregateReporter) AddBundle(bundle *explorer.Bundle) { + r.bundle = bundle } func (r *AggregateReporter) AddScanError(asset *inventory.Asset, err error) {