@@ -23,6 +23,7 @@ import (
2323 "net/http"
2424 "reflect"
2525 sysruntime "runtime"
26+ "slices"
2627 "strconv"
2728 "strings"
2829 "sync"
@@ -1496,7 +1497,7 @@ func evaluateFinalizerTests(ctrl *csiSnapshotCommonController, reactor *snapshot
14961497 if funcName == "testAddPVCFinalizer" {
14971498 for _ , pvc := range reactor .claims {
14981499 if test .initialClaims [0 ].Name == pvc .Name {
1499- if ! utils . ContainsString (test .initialClaims [0 ].ObjectMeta .Finalizers , utils .PVCFinalizer ) && utils . ContainsString (pvc .ObjectMeta .Finalizers , utils .PVCFinalizer ) {
1500+ if ! slices . Contains (test .initialClaims [0 ].ObjectMeta .Finalizers , utils .PVCFinalizer ) && slices . Contains (pvc .ObjectMeta .Finalizers , utils .PVCFinalizer ) {
15001501 klog .V (4 ).Infof ("test %q succeeded. PVCFinalizer is added to PVC %s" , test .name , pvc .Name )
15011502 bHasPVCFinalizer = true
15021503 }
@@ -1511,7 +1512,7 @@ func evaluateFinalizerTests(ctrl *csiSnapshotCommonController, reactor *snapshot
15111512 if funcName == "testRemovePVCFinalizer" {
15121513 for _ , pvc := range reactor .claims {
15131514 if test .initialClaims [0 ].Name == pvc .Name {
1514- if utils . ContainsString (test .initialClaims [0 ].ObjectMeta .Finalizers , utils .PVCFinalizer ) && ! utils . ContainsString (pvc .ObjectMeta .Finalizers , utils .PVCFinalizer ) {
1515+ if slices . Contains (test .initialClaims [0 ].ObjectMeta .Finalizers , utils .PVCFinalizer ) && ! slices . Contains (pvc .ObjectMeta .Finalizers , utils .PVCFinalizer ) {
15151516 klog .V (4 ).Infof ("test %q succeeded. PVCFinalizer is removed from PVC %s" , test .name , pvc .Name )
15161517 bHasPVCFinalizer = false
15171518 }
@@ -1526,10 +1527,10 @@ func evaluateFinalizerTests(ctrl *csiSnapshotCommonController, reactor *snapshot
15261527 if funcName == "testAddSnapshotFinalizer" {
15271528 for _ , snapshot := range reactor .snapshots {
15281529 if test .initialSnapshots [0 ].Name == snapshot .Name {
1529- if ! utils . ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1530- utils . ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1531- ! utils . ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) &&
1532- utils . ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
1530+ if ! slices . Contains (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1531+ slices . Contains (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1532+ ! slices . Contains (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) &&
1533+ slices . Contains (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
15331534 klog .V (4 ).Infof ("test %q succeeded. Finalizers are added to snapshot %s" , test .name , snapshot .Name )
15341535 bHasSnapshotFinalizer = true
15351536 }
@@ -1544,10 +1545,10 @@ func evaluateFinalizerTests(ctrl *csiSnapshotCommonController, reactor *snapshot
15441545 if funcName == "testRemoveSnapshotFinalizer" {
15451546 for _ , snapshot := range reactor .snapshots {
15461547 if test .initialSnapshots [0 ].Name == snapshot .Name {
1547- if utils . ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1548- ! utils . ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1549- utils . ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) &&
1550- ! utils . ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
1548+ if slices . Contains (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1549+ ! slices . Contains (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1550+ slices . Contains (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) &&
1551+ ! slices . Contains (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
15511552
15521553 klog .V (4 ).Infof ("test %q succeeded. SnapshotFinalizer is removed from Snapshot %s" , test .name , snapshot .Name )
15531554 bHasSnapshotFinalizer = false
0 commit comments