Skip to content

Commit

Permalink
Clean 'scan cache clean' code and add timeout to it
Browse files Browse the repository at this point in the history
  • Loading branch information
romulets committed Aug 13, 2024
1 parent 676e11f commit b6c76f6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions internal/vulnerability/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package vulnerability

import (
"context"
"errors"
"time"

"github.com/aquasecurity/trivy/pkg/commands/artifact"
Expand Down Expand Up @@ -86,12 +85,12 @@ func clearTrivyCache(ctx context.Context, log *logp.Logger) error {
log.Info("Starting VulnerabilityRunner.ClearCache")
defer log.Info("Ending VulnerabilityRunner.ClearCache")

err := clean.Run(ctx, flag.Options{CleanOptions: flag.CleanOptions{CleanScanCache: true}})
if err != nil {
if !errors.Is(err, artifact.SkipScan) {
return err
}
}

return nil
return clean.Run(ctx, flag.Options{
CleanOptions: flag.CleanOptions{
CleanScanCache: true,
},
GlobalOptions: flag.GlobalOptions{
Timeout: 5 * time.Second,
},
})
}

0 comments on commit b6c76f6

Please sign in to comment.