Skip to content

Commit

Permalink
Fallback to dktest.DefaultCleanupTimeout if the dktest.Options doesn'…
Browse files Browse the repository at this point in the history
…t have one specified
  • Loading branch information
dhui committed Apr 16, 2024
1 parent b1d02e2 commit f4950c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dktesting/dktesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func (s *ContainerSpec) Cleanup() (retErr error) {
retErr = fmt.Errorf("error closing Docker client: %w", err)
}
}()
ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), s.Options.CleanupTimeout)
cleanupTimeout := s.Options.CleanupTimeout
if cleanupTimeout <= 0 {
cleanupTimeout = dktest.DefaultCleanupTimeout
}
ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), cleanupTimeout)
defer timeoutCancelFunc()
if _, err := dc.ImageRemove(ctx, s.ImageName, types.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil {
return err
Expand Down

0 comments on commit f4950c1

Please sign in to comment.