controllers: check if != nil before defering

This commit is contained in:
Hidde Beydals 2020-04-16 11:11:51 +02:00
parent 47c7197dfa
commit ab3879d170
2 changed files with 6 additions and 2 deletions

View File

@ -182,7 +182,9 @@ func (r *HelmChartReconciler) sync(repository sourcev1.HelmRepository, chart sou
err = fmt.Errorf("auth options error: %w", err)
return sourcev1.HelmChartNotReady(chart, sourcev1.AuthenticationFailedReason, err.Error()), err
}
defer cleanup()
if cleanup != nil {
defer cleanup()
}
clientOpts = opts
}

View File

@ -137,7 +137,9 @@ func (r *HelmRepositoryReconciler) sync(repository sourcev1.HelmRepository) (sou
err = fmt.Errorf("auth options error: %w", err)
return sourcev1.HelmRepositoryNotReady(repository, sourcev1.AuthenticationFailedReason, err.Error()), err
}
defer cleanup()
if cleanup != nil {
defer cleanup()
}
clientOpts = opts
}