@@ -202,6 +202,21 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
202202 var reconcileErr error
203203 switch typedSource := source .(type ) {
204204 case * sourcev1.HelmRepository :
205+ // TODO: move this to a validation webhook once the discussion around
206+ // certificates has settled: https://github.com/fluxcd/image-reflector-controller/issues/69
207+ if err := validHelmChartName (chart .Spec .Chart ); err != nil {
208+ reconciledChart = sourcev1 .HelmChartNotReady (chart , sourcev1 .ChartPullFailedReason , err .Error ())
209+ log .Error (err , "validation failed" )
210+ if err := r .updateStatus (ctx , req , reconciledChart .Status ); err != nil {
211+ log .Info (fmt .Sprintf ("%v" , reconciledChart .Status ))
212+ log .Error (err , "unable to update status" )
213+ return ctrl.Result {Requeue : true }, err
214+ }
215+ r .event (ctx , reconciledChart , events .EventSeverityError , err .Error ())
216+ r .recordReadiness (ctx , reconciledChart )
217+ // Do not requeue as there is no chance on recovery.
218+ return ctrl.Result {Requeue : false }, nil
219+ }
205220 reconciledChart , reconcileErr = r .reconcileFromHelmRepository (ctx , * typedSource , * chart .DeepCopy (), changed )
206221 case * sourcev1.GitRepository , * sourcev1.Bucket :
207222 reconciledChart , reconcileErr = r .reconcileFromTarballArtifact (ctx , * typedSource .GetArtifact (),
@@ -279,12 +294,6 @@ func (r *HelmChartReconciler) getSource(ctx context.Context, chart sourcev1.Helm
279294
280295func (r * HelmChartReconciler ) reconcileFromHelmRepository (ctx context.Context ,
281296 repository sourcev1.HelmRepository , chart sourcev1.HelmChart , force bool ) (sourcev1.HelmChart , error ) {
282- // TODO: move this to a validation webhook once the discussion around
283- // certificates has settled: https://github.com/fluxcd/image-reflector-controller/issues/69
284- if err := validHelmChartName (chart .Spec .Chart ); err != nil {
285- return sourcev1 .HelmChartNotReady (chart , sourcev1 .ChartPullFailedReason , err .Error ()), nil
286- }
287-
288297 // Configure ChartRepository getter options
289298 var clientOpts []getter.Option
290299 if secret , err := r .getHelmRepositorySecret (ctx , & repository ); err != nil {
0 commit comments