@@ -51,18 +51,18 @@ import (
5151var helmRepositoryOCIReadyCondition = summarize.Conditions {
5252 Target : meta .ReadyCondition ,
5353 Owned : []string {
54- sourcev1 .FetchFailedCondition ,
54+ sourcev1 .AddFailedCondition ,
5555 meta .ReadyCondition ,
5656 meta .ReconcilingCondition ,
5757 meta .StalledCondition ,
5858 },
5959 Summarize : []string {
60- sourcev1 .FetchFailedCondition ,
60+ sourcev1 .AddFailedCondition ,
6161 meta .StalledCondition ,
6262 meta .ReconcilingCondition ,
6363 },
6464 NegativePolarity : []string {
65- sourcev1 .FetchFailedCondition ,
65+ sourcev1 .AddFailedCondition ,
6666 meta .StalledCondition ,
6767 meta .ReconcilingCondition ,
6868 },
@@ -71,7 +71,7 @@ var helmRepositoryOCIReadyCondition = summarize.Conditions{
7171// helmRepositoryOCIFailConditions contains the conditions that represent a
7272// failure.
7373var helmRepositoryOCIFailConditions = []string {
74- sourcev1 .FetchFailedCondition ,
74+ sourcev1 .AddFailedCondition ,
7575}
7676
7777// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmrepositories,verbs=get;list;watch;create;update;patch;delete
@@ -188,7 +188,8 @@ func (r *HelmRepositoryOCIReconciler) Reconcile(ctx context.Context, req ctrl.Re
188188
189189 // Examine if a type change has happened and act accordingly
190190 if obj .Spec .Type != sourcev1 .HelmRepositoryTypeOCI {
191- // just ignore the object if the type has changed
191+ // remove any stale condition and ignore the object if the type has changed
192+ obj .Status .Conditions = nil
192193 recResult , retErr = sreconcile .ResultEmpty , nil
193194 return
194195 }
@@ -258,10 +259,10 @@ func (r *HelmRepositoryOCIReconciler) reconcile(ctx context.Context, obj *source
258259func (r * HelmRepositoryOCIReconciler ) reconcileSource (ctx context.Context , obj * sourcev1.HelmRepository ) (sreconcile.Result , error ) {
259260 if ! helmreg .IsOCI (obj .Spec .URL ) {
260261 e := & serror.Stalling {
261- Err : fmt .Errorf ("the url scheme is not supported: %s" , obj .Spec .URL ),
262+ Err : fmt .Errorf ("the URL scheme is not supported: %s" , obj .Spec .URL ),
262263 Reason : sourcev1 .URLInvalidReason ,
263264 }
264- conditions .MarkFalse (obj , meta . ReadyCondition , e .Reason , e .Err .Error ())
265+ conditions .MarkTrue (obj , sourcev1 . AddFailedCondition , e .Reason , e .Err .Error ())
265266 return sreconcile .ResultEmpty , e
266267 }
267268
@@ -279,7 +280,7 @@ func (r *HelmRepositoryOCIReconciler) reconcileSource(ctx context.Context, obj *
279280 Err : fmt .Errorf ("failed to get secret '%s': %w" , name .String (), err ),
280281 Reason : sourcev1 .AuthenticationFailedReason ,
281282 }
282- conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Err .Error ())
283+ conditions .MarkTrue (obj , sourcev1 .AddFailedCondition , e .Reason , e .Err .Error ())
283284 return sreconcile .ResultEmpty , e
284285 }
285286
@@ -290,7 +291,7 @@ func (r *HelmRepositoryOCIReconciler) reconcileSource(ctx context.Context, obj *
290291 Err : fmt .Errorf ("failed to configure Helm client with secret data: %w" , err ),
291292 Reason : sourcev1 .AuthenticationFailedReason ,
292293 }
293- conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Err .Error ())
294+ conditions .MarkTrue (obj , sourcev1 .AddFailedCondition , e .Reason , e .Err .Error ())
294295 // Return err as the content of the secret may change.
295296 return sreconcile .ResultEmpty , e
296297 }
@@ -309,10 +310,10 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
309310 registryClient , file , err := r .RegistryClientGenerator (logOpts != nil )
310311 if err != nil {
311312 e := & serror.Event {
312- Err : fmt .Errorf ("failed to create registry client:: %w" , err ),
313+ Err : fmt .Errorf ("failed to create registry client: %w" , err ),
313314 Reason : meta .FailedReason ,
314315 }
315- conditions .MarkFalse (obj , meta . ReadyCondition , e .Reason , e .Err .Error ())
316+ conditions .MarkTrue (obj , sourcev1 . AddFailedCondition , e .Reason , e .Err .Error ())
316317 return sreconcile .ResultEmpty , e
317318 }
318319
@@ -331,23 +332,25 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
331332 Err : fmt .Errorf ("failed to parse URL '%s': %w" , obj .Spec .URL , err ),
332333 Reason : sourcev1 .URLInvalidReason ,
333334 }
334- conditions .MarkFalse (obj , meta . ReadyCondition , e .Reason , e .Err .Error ())
335+ conditions .MarkTrue (obj , sourcev1 . AddFailedCondition , e .Reason , e .Err .Error ())
335336 return sreconcile .ResultEmpty , e
336337 }
337338
338- // Attempt to login to the registry if credentials are provided.
339339 if logOpts != nil {
340340 err = chartRepo .Login (logOpts ... )
341341 if err != nil {
342342 e := & serror.Event {
343- Err : fmt .Errorf ("failed to create temporary file : %w" , err ),
343+ Err : fmt .Errorf ("failed to login to repository '%s' : %w" , obj . Spec . URL , err ),
344344 Reason : meta .FailedReason ,
345345 }
346- conditions .MarkFalse (obj , meta . ReadyCondition , e .Reason , e .Err .Error ())
346+ conditions .MarkTrue (obj , sourcev1 . AddFailedCondition , e .Reason , e .Err .Error ())
347347 return sreconcile .ResultEmpty , e
348348 }
349349 }
350350
351+ // Delete any stale failure observation
352+ conditions .Delete (obj , sourcev1 .AddFailedCondition )
353+
351354 conditions .MarkTrue (obj , meta .ReadyCondition , meta .SucceededReason , "Helm repository %q is ready" , obj .Name )
352355
353356 return sreconcile .ResultSuccess , nil
0 commit comments