Merge pull request #25 from fluxcd/check-nil-cleanup

controllers: check if != nil before defering
This commit is contained in:
Hidde Beydals 2020-04-16 11:24:21 +02:00 committed by GitHub
commit 96c7ad502c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}