Skip to content

Commit

Permalink
🧹 handle auto update config in serve command (#1203)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Mar 27, 2024
1 parent 880b016 commit ffade41
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/cnspec/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,18 @@ var serveCmd = &cobra.Command{
return cli_errors.NewCommandError(errors.Wrap(err, "could not start background listener"), 1)
}

autoUpdate := true
if viper.IsSet("auto_update") {
autoUpdate = viper.GetBool("auto_update")
}

bj.Run(func() error {
// Try to update the os provider before each scan
err = updateProviders()
if err != nil {
log.Error().Err(err).Msg("could not update providers")
if autoUpdate {
err = updateProviders()
if err != nil {
log.Error().Err(err).Msg("could not update providers")
}
}
// TODO: check in every 5 min via timer, init time in Background job
result, err := RunScan(scanConf, scan.DisableProgressBar(), scan.WithReportType(scan.ReportType_ERROR))
Expand Down

0 comments on commit ffade41

Please sign in to comment.