Skip to content

Commit

Permalink
Merge pull request #180 from anchore/always-report-on-failure
Browse files Browse the repository at this point in the history
fix: ensure that inventory report is logged on post error
  • Loading branch information
bradleyjones authored Mar 21, 2024
2 parents b19829c + 0e09f13 commit 1b5945f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func reportToStdout(report inventory.Report) error {
}

func HandleReport(report inventory.Report, cfg *config.Application) error {
if cfg.VerboseInventoryReports {
err := reportToStdout(report)
if err != nil {
log.Errorf("Failed to output Inventory Report: %w", err)
}
}

if cfg.AnchoreDetails.IsValid() {
if err := reporter.Post(report, cfg.AnchoreDetails); err != nil {
return fmt.Errorf("unable to report Inventory to Anchore: %w", err)
Expand All @@ -52,10 +59,6 @@ func HandleReport(report inventory.Report, cfg *config.Application) error {
} else {
log.Info("Anchore details not specified, not reporting inventory")
}

if cfg.VerboseInventoryReports {
return reportToStdout(report)
}
return nil
}

Expand Down

0 comments on commit 1b5945f

Please sign in to comment.