@@ -473,17 +473,16 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
473
473
if err != nil {
474
474
e := & serror.Event {
475
475
Err : fmt .Errorf ("failed to get public key for chart signature verification: %w" , err ),
476
- Reason : sourcev1 .AuthenticationFailedReason ,
476
+ Reason : sourcev1 .VerificationFailedReason ,
477
477
}
478
- conditions .MarkFalse (obj , sourcev1 .SourceVerifiedCondition , e .Reason , e .Error ())
478
+ conditions .MarkFalse (obj , sourcev1 .SourceVerifiedCondition , e .Reason , e .Err . Error ())
479
479
return sreconcile .ResultEmpty , e
480
480
}
481
481
opts .Keyring = keyring
482
482
483
483
// Build the chart
484
484
ref := chart.RemoteReference {Name : obj .Spec .Chart , Version : obj .Spec .Version }
485
485
build , err := cb .Build (ctx , ref , util .TempPathForObj ("" , ".tgz" , obj ), opts )
486
-
487
486
if err != nil {
488
487
return sreconcile .ResultEmpty , err
489
488
}
@@ -607,9 +606,9 @@ func (r *HelmChartReconciler) buildFromTarballArtifact(ctx context.Context, obj
607
606
if err != nil {
608
607
e := & serror.Event {
609
608
Err : fmt .Errorf ("failed to get public key for chart signature verification: %w" , err ),
610
- Reason : sourcev1 .AuthenticationFailedReason ,
609
+ Reason : sourcev1 .VerificationFailedReason ,
611
610
}
612
- conditions .MarkFalse (obj , sourcev1 .SourceVerifiedCondition , e .Reason , e .Error ())
611
+ conditions .MarkFalse (obj , sourcev1 .SourceVerifiedCondition , e .Reason , e .Err . Error ())
613
612
return sreconcile .ResultEmpty , e
614
613
}
615
614
opts .Keyring = keyring
@@ -698,10 +697,11 @@ func (r *HelmChartReconciler) reconcileArtifact(ctx context.Context, obj *source
698
697
if b .ProvFilePath != "" {
699
698
provArtifact := r .Storage .NewArtifactFor (obj .Kind , obj .GetObjectMeta (), b .Version , fmt .Sprintf ("%s-%s.tgz.prov" , b .Name , b .Version ))
700
699
if err = r .Storage .CopyFromPath (& provArtifact , b .ProvFilePath ); err != nil {
701
- return sreconcile . ResultEmpty , & serror.Event {
700
+ e := & serror.Event {
702
701
Err : fmt .Errorf ("unable to copy Helm chart provenance file to storage: %w" , err ),
703
- Reason : sourcev1 .StorageOperationFailedCondition ,
702
+ Reason : sourcev1 .ArchiveOperationFailedReason ,
704
703
}
704
+ conditions .MarkTrue (obj , sourcev1 .StorageOperationFailedCondition , e .Reason , e .Err .Error ())
705
705
}
706
706
}
707
707
@@ -803,14 +803,13 @@ func (r *HelmChartReconciler) garbageCollect(ctx context.Context, obj *sourcev1.
803
803
localPath := r .Storage .LocalPath (* obj .GetArtifact ())
804
804
provFilePath := localPath + ".prov"
805
805
dir := filepath .Dir (localPath )
806
- callbacks := make ([]func (path string , info os.FileInfo ) bool , 0 )
807
- callbacks = append (callbacks , func (path string , info os.FileInfo ) bool {
806
+ callback := func (path string , info os.FileInfo ) bool {
808
807
if path != localPath && path != provFilePath && info .Mode ()& os .ModeSymlink != os .ModeSymlink {
809
808
return true
810
809
}
811
810
return false
812
- })
813
- if _ , err := r .Storage .RemoveConditionally (dir , callbacks ); err != nil {
811
+ }
812
+ if _ , err := r .Storage .RemoveConditionally (dir , callback ); err != nil {
814
813
return & serror.Event {
815
814
Err : fmt .Errorf ("garbage collection of old artifacts failed: %w" , err ),
816
815
Reason : "GarbageCollectionFailed" ,
@@ -1036,11 +1035,13 @@ func observeChartBuild(obj *sourcev1.HelmChart, build *chart.Build, err error) {
1036
1035
1037
1036
if build .VerificationSignature != nil && build .ProvFilePath != "" {
1038
1037
var sigVerMsg strings.Builder
1039
- sigVerMsg .WriteString (fmt .Sprintf ("chart signed by: %v " , strings .Join (build .VerificationSignature .Identities [:], "," )))
1040
- sigVerMsg .WriteString (fmt .Sprintf (" using key with fingeprint: %X " , build .VerificationSignature .KeyFingerprint ))
1041
- sigVerMsg .WriteString (fmt .Sprintf (" and hash verified: %s " , build .VerificationSignature .FileHash ))
1038
+ sigVerMsg .WriteString (fmt .Sprintf ("chart signed by: '%v' " , strings .Join (build .VerificationSignature .Identities [:], "," )))
1039
+ sigVerMsg .WriteString (fmt .Sprintf (" using key with fingeprint: '%X' " , build .VerificationSignature .KeyFingerprint ))
1040
+ sigVerMsg .WriteString (fmt .Sprintf (" and hash verified: '%s' " , build .VerificationSignature .FileHash ))
1042
1041
1043
1042
conditions .MarkTrue (obj , sourcev1 .SourceVerifiedCondition , sourcev1 .ChartVerifiedSucceededReason , sigVerMsg .String ())
1043
+ } else {
1044
+ conditions .Delete (obj , sourcev1 .SourceVerifiedCondition )
1044
1045
}
1045
1046
1046
1047
if err != nil {
0 commit comments