@@ -372,6 +372,12 @@ func (r *HelmChartReconciler) reconcileStorage(ctx context.Context, obj *sourcev
372372}
373373
374374func (r * HelmChartReconciler ) reconcileSource (ctx context.Context , obj * sourcev1.HelmChart , build * chart.Build ) (_ sreconcile.Result , retErr error ) {
375+ // Remove any failed verification condition.
376+ // The reason is that a failing verification should be recalculated.
377+ if conditions .IsFalse (obj , sourcev1 .SourceVerifiedCondition ) {
378+ conditions .Delete (obj , sourcev1 .SourceVerifiedCondition )
379+ }
380+
375381 // Retrieve the source
376382 s , err := r .getSource (ctx , obj )
377383 if err != nil {
@@ -577,10 +583,10 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
577583 if obj .Spec .Verify .SecretRef == nil {
578584 provider = fmt .Sprintf ("%s keyless" , provider )
579585 }
580- e := serror .NewGeneric (
581- fmt .Errorf ("failed to verify the signature using provider '%s': %w" , provider , err ),
582- sourcev1 .VerificationError ,
583- )
586+ e := & serror.Event {
587+ Err : fmt .Errorf ("failed to verify the signature using provider '%s': %w" , provider , err ),
588+ Reason : sourcev1 .VerificationError ,
589+ }
584590 conditions .MarkFalse (obj , sourcev1 .SourceVerifiedCondition , e .Reason , e .Err .Error ())
585591 return sreconcile .ResultEmpty , e
586592 }
@@ -650,15 +656,8 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
650656 Force : obj .Generation != obj .Status .ObservedGeneration ,
651657 // The remote builder will not attempt to download the chart if
652658 // an artifact exists with the same name and version and `Force` is false.
653- // It will try to verify the chart if:
654- // - we are on the first reconciliation
655- // - the HelmChart spec has changed (generation drift)
656- // - the previous reconciliation resulted in a failed artifact verification
657- // - there is no artifact in storage
658- Verify : obj .Spec .Verify != nil && (obj .Generation <= 0 ||
659- conditions .GetObservedGeneration (obj , sourcev1 .SourceVerifiedCondition ) != obj .Generation ||
660- conditions .IsFalse (obj , sourcev1 .SourceVerifiedCondition ) ||
661- obj .GetArtifact () == nil ),
659+ // It will however try to verify the chart if `obj.Spec.Verify` is set, at every reconciliation.
660+ Verify : obj .Spec .Verify != nil && obj .Spec .Verify .Provider != "" ,
662661 }
663662 if artifact := obj .GetArtifact (); artifact != nil {
664663 opts .CachedChart = r .Storage .LocalPath (* artifact )
@@ -1293,9 +1292,13 @@ func observeChartBuild(obj *sourcev1.HelmChart, build *chart.Build, err error) {
12931292 }
12941293
12951294 switch buildErr .Reason {
1296- case chart .ErrChartMetadataPatch , chart .ErrValuesFilesMerge , chart .ErrDependencyBuild , chart .ErrChartPackage , chart .ErrChartVerification :
1295+ case chart .ErrChartMetadataPatch , chart .ErrValuesFilesMerge , chart .ErrDependencyBuild , chart .ErrChartPackage :
1296+ conditions .Delete (obj , sourcev1 .FetchFailedCondition )
1297+ conditions .MarkTrue (obj , sourcev1 .BuildFailedCondition , buildErr .Reason .Reason , buildErr .Error ())
1298+ case chart .ErrChartVerification :
12971299 conditions .Delete (obj , sourcev1 .FetchFailedCondition )
12981300 conditions .MarkTrue (obj , sourcev1 .BuildFailedCondition , buildErr .Reason .Reason , buildErr .Error ())
1301+ conditions .MarkFalse (obj , sourcev1 .SourceVerifiedCondition , sourcev1 .VerificationError , buildErr .Error ())
12991302 default :
13001303 conditions .Delete (obj , sourcev1 .BuildFailedCondition )
13011304 conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , buildErr .Reason .Reason , buildErr .Error ())
0 commit comments