Skip to content

Commit

Permalink
Fix --timeout flag (#569)
Browse files Browse the repository at this point in the history
* Wrapped scan call inside context timeout

* timeout has default value
  • Loading branch information
rahul2393 committed Jul 22, 2020
1 parent 9c6f077 commit d6b37cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func run(c config.Config, initializeScanner InitializeScanner) error {
target = c.Input
}

ctx := context.Background()
ctx, cancel := context.WithTimeout(context.Background(), c.Timeout)
defer cancel()
scanner, cleanup, err := initializeScanner(ctx, target, cacheClient, cacheClient, c.Timeout)
if err != nil {
return xerrors.Errorf("unable to initialize a scanner: %w", err)
Expand Down
3 changes: 2 additions & 1 deletion internal/client/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func run(c config.Config) (err error) {
}

var scanner scanner.Scanner
ctx := context.Background()
ctx, cancel := context.WithTimeout(context.Background(), c.Timeout)
defer cancel()
remoteCache := cache.NewRemoteCache(cache.RemoteURL(c.RemoteAddr), c.CustomHeaders)

cleanup := func() {}
Expand Down

0 comments on commit d6b37cb

Please sign in to comment.