Don't use time.Tick to prevent leaks

Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
James Munnelly 2019-12-16 12:45:49 +00:00
parent 45785999f9
commit df27fff9ce

View File

@ -89,11 +89,13 @@ func (f *FileCertificateSource) Run(stopCh <-chan struct{}) error {
}
failures := 0
ticker := time.NewTicker(updateInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return nil
case <-time.Tick(updateInterval):
case <-ticker.C:
if err := f.updateCertificateFromDisk(); err != nil {
failures++
f.Log.Error(err, "failed to update certificate from disk", "failures", failures)