Skip to content

Commit ab3879d

Browse files
committed
controllers: check if != nil before defering
1 parent 47c7197 commit ab3879d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

controllers/helmchart_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ func (r *HelmChartReconciler) sync(repository sourcev1.HelmRepository, chart sou
182182
err = fmt.Errorf("auth options error: %w", err)
183183
return sourcev1.HelmChartNotReady(chart, sourcev1.AuthenticationFailedReason, err.Error()), err
184184
}
185-
defer cleanup()
185+
if cleanup != nil {
186+
defer cleanup()
187+
}
186188
clientOpts = opts
187189
}
188190

controllers/helmrepository_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ func (r *HelmRepositoryReconciler) sync(repository sourcev1.HelmRepository) (sou
137137
err = fmt.Errorf("auth options error: %w", err)
138138
return sourcev1.HelmRepositoryNotReady(repository, sourcev1.AuthenticationFailedReason, err.Error()), err
139139
}
140-
defer cleanup()
140+
if cleanup != nil {
141+
defer cleanup()
142+
}
141143
clientOpts = opts
142144
}
143145

0 commit comments

Comments
 (0)