@@ -164,11 +164,13 @@ type reactorError struct {
164164 error error
165165}
166166
167- func withSnapshotFinalizer (snapshot * crdv1.VolumeSnapshot ) * crdv1.VolumeSnapshot {
168- snapshot .ObjectMeta .Finalizers = append (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotContentFinalizer )
169- snapshot .ObjectMeta .Finalizers = append (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer )
170- snapshot .ObjectMeta .Finalizers = append (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer )
171- return snapshot
167+ func withSnapshotFinalizers (snapshots []* crdv1.VolumeSnapshot , finalizers ... string ) []* crdv1.VolumeSnapshot {
168+ for i := range snapshots {
169+ for _ , f := range finalizers {
170+ snapshots [i ].ObjectMeta .Finalizers = append (snapshots [i ].ObjectMeta .Finalizers , f )
171+ }
172+ }
173+ return snapshots
172174}
173175
174176func withContentFinalizer (content * crdv1.VolumeSnapshotContent ) * crdv1.VolumeSnapshotContent {
@@ -863,7 +865,7 @@ func newContentWithUnmatchDriverArray(contentName, boundToSnapshotUID, boundToSn
863865func newSnapshot (
864866 snapshotName , snapshotUID , pvcName , targetContentName , snapshotClassName , boundContentName string ,
865867 readyToUse * bool , creationTime * metav1.Time , restoreSize * resource.Quantity ,
866- err * crdv1.VolumeSnapshotError , nilStatus bool , withFinalizer bool , deletionTimestamp * metav1.Time ) * crdv1.VolumeSnapshot {
868+ err * crdv1.VolumeSnapshotError , nilStatus bool , withAllFinalizers bool , deletionTimestamp * metav1.Time ) * crdv1.VolumeSnapshot {
867869 snapshot := crdv1.VolumeSnapshot {
868870 ObjectMeta : metav1.ObjectMeta {
869871 Name : snapshotName ,
@@ -904,18 +906,18 @@ func newSnapshot(
904906 VolumeSnapshotContentName : & targetContentName ,
905907 }
906908 }
907- if withFinalizer {
908- return withSnapshotFinalizer ( & snapshot )
909+ if withAllFinalizers {
910+ return withSnapshotFinalizers ([] * crdv1. VolumeSnapshot { & snapshot }, utils . VolumeSnapshotContentFinalizer , utils . VolumeSnapshotAsSourceFinalizer , utils . VolumeSnapshotBoundFinalizer )[ 0 ]
909911 }
910912 return & snapshot
911913}
912914
913915func newSnapshotArray (
914916 snapshotName , snapshotUID , pvcName , targetContentName , snapshotClassName , boundContentName string ,
915917 readyToUse * bool , creationTime * metav1.Time , restoreSize * resource.Quantity ,
916- err * crdv1.VolumeSnapshotError , nilStatus bool , withFinalizer bool , deletionTimestamp * metav1.Time ) []* crdv1.VolumeSnapshot {
918+ err * crdv1.VolumeSnapshotError , nilStatus bool , withAllFinalizers bool , deletionTimestamp * metav1.Time ) []* crdv1.VolumeSnapshot {
917919 return []* crdv1.VolumeSnapshot {
918- newSnapshot (snapshotName , snapshotUID , pvcName , targetContentName , snapshotClassName , boundContentName , readyToUse , creationTime , restoreSize , err , nilStatus , withFinalizer , deletionTimestamp ),
920+ newSnapshot (snapshotName , snapshotUID , pvcName , targetContentName , snapshotClassName , boundContentName , readyToUse , creationTime , restoreSize , err , nilStatus , withAllFinalizers , deletionTimestamp ),
919921 }
920922}
921923
0 commit comments