build: address 'intrange' linter warning

golangci-lint warns about this:

    for loop can be changed to use an integer range (Go 1.22+)
    (intrange)

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2024-04-26 10:49:26 +02:00 committed by mergify[bot]
parent 0e7b06e9d0
commit e85914fc0d
10 changed files with 46 additions and 46 deletions

View File

@ -874,7 +874,7 @@ var _ = Describe(cephfsType, func() {
} }
app.Namespace = f.UniqueName app.Namespace = f.UniqueName
// create PVC and app // create PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
err = createPVCAndApp(name, f, pvc, app, deployTimeout) err = createPVCAndApp(name, f, pvc, app, deployTimeout)
if err != nil { if err != nil {
@ -889,7 +889,7 @@ var _ = Describe(cephfsType, func() {
validateSubvolumeCount(f, totalCount, fileSystemName, subvolumegroup) validateSubvolumeCount(f, totalCount, fileSystemName, subvolumegroup)
validateOmapCount(f, totalCount, cephfsType, metadataPool, volumesType) validateOmapCount(f, totalCount, cephfsType, metadataPool, volumesType)
// delete PVC and app // delete PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
err = deletePVCAndApp(name, f, pvc, app) err = deletePVCAndApp(name, f, pvc, app)
if err != nil { if err != nil {
@ -1452,7 +1452,7 @@ var _ = Describe(cephfsType, func() {
snap.Namespace = f.UniqueName snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot // create snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout) wgErrs[n] = createSnapshot(&s, deployTimeout)
@ -1488,7 +1488,7 @@ var _ = Describe(cephfsType, func() {
// create multiple PVC from same snapshot // create multiple PVC from same snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
@ -1520,7 +1520,7 @@ var _ = Describe(cephfsType, func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -1548,7 +1548,7 @@ var _ = Describe(cephfsType, func() {
// create clones from different snapshots and bind it to an // create clones from different snapshots and bind it to an
// app // app
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -1581,7 +1581,7 @@ var _ = Describe(cephfsType, func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete snapshot // delete snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = deleteSnapshot(&s, deployTimeout) wgErrs[n] = deleteSnapshot(&s, deployTimeout)
@ -1605,7 +1605,7 @@ var _ = Describe(cephfsType, func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -2308,7 +2308,7 @@ var _ = Describe(cephfsType, func() {
appClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName
wg.Add(totalCount) wg.Add(totalCount)
// create clone and bind it to an app // create clone and bind it to an app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
@ -2340,7 +2340,7 @@ var _ = Describe(cephfsType, func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name

View File

@ -528,7 +528,7 @@ var _ = Describe("nfs", func() {
} }
app.Namespace = f.UniqueName app.Namespace = f.UniqueName
// create PVC and app // create PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
err = createPVCAndApp(name, f, pvc, app, deployTimeout) err = createPVCAndApp(name, f, pvc, app, deployTimeout)
if err != nil { if err != nil {
@ -542,7 +542,7 @@ var _ = Describe("nfs", func() {
validateSubvolumeCount(f, totalCount, fileSystemName, defaultSubvolumegroup) validateSubvolumeCount(f, totalCount, fileSystemName, defaultSubvolumegroup)
// delete PVC and app // delete PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
err = deletePVCAndApp(name, f, pvc, app) err = deletePVCAndApp(name, f, pvc, app)
if err != nil { if err != nil {
@ -699,7 +699,7 @@ var _ = Describe("nfs", func() {
snap.Namespace = f.UniqueName snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot // create snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout) wgErrs[n] = createSnapshot(&s, deployTimeout)
@ -736,7 +736,7 @@ var _ = Describe("nfs", func() {
// create multiple PVC from same snapshot // create multiple PVC from same snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
@ -790,7 +790,7 @@ var _ = Describe("nfs", func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -817,7 +817,7 @@ var _ = Describe("nfs", func() {
validateOmapCount(f, totalCount, cephfsType, metadataPool, snapsType) validateOmapCount(f, totalCount, cephfsType, metadataPool, snapsType)
// create clones from different snapshots and bind it to an app // create clones from different snapshots and bind it to an app
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -872,7 +872,7 @@ var _ = Describe("nfs", func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete snapshot // delete snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = deleteSnapshot(&s, deployTimeout) wgErrs[n] = deleteSnapshot(&s, deployTimeout)
@ -896,7 +896,7 @@ var _ = Describe("nfs", func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -980,7 +980,7 @@ var _ = Describe("nfs", func() {
appClone.Labels = label appClone.Labels = label
wg.Add(totalCount) wg.Add(totalCount)
// create clone and bind it to an app // create clone and bind it to an app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
@ -1036,7 +1036,7 @@ var _ = Describe("nfs", func() {
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name

View File

@ -2721,7 +2721,7 @@ var _ = Describe("RBD", func() {
} }
app.Namespace = f.UniqueName app.Namespace = f.UniqueName
// create PVC and app // create PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
err := createPVCAndApp(name, f, pvc, app, deployTimeout) err := createPVCAndApp(name, f, pvc, app, deployTimeout)
if err != nil { if err != nil {
@ -2733,7 +2733,7 @@ var _ = Describe("RBD", func() {
validateRBDImageCount(f, totalCount, defaultRBDPool) validateRBDImageCount(f, totalCount, defaultRBDPool)
validateOmapCount(f, totalCount, rbdType, defaultRBDPool, volumesType) validateOmapCount(f, totalCount, rbdType, defaultRBDPool, volumesType)
// delete PVC and app // delete PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
err := deletePVCAndApp(name, f, pvc, app) err := deletePVCAndApp(name, f, pvc, app)
if err != nil { if err != nil {
@ -3316,7 +3316,7 @@ var _ = Describe("RBD", func() {
appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
// create PVC and app // create PVC and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
label := map[string]string{ label := map[string]string{
"app": name, "app": name,
@ -3329,7 +3329,7 @@ var _ = Describe("RBD", func() {
} }
} }
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=" + name, LabelSelector: "app=" + name,
@ -3348,7 +3348,7 @@ var _ = Describe("RBD", func() {
} }
// delete app // delete app
for i := 0; i < totalCount; i++ { for i := range totalCount {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
appClone.Name = name appClone.Name = name
err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout) err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout)
@ -3552,7 +3552,7 @@ var _ = Describe("RBD", func() {
// validate created backend rbd images // validate created backend rbd images
validateRBDImageCount(f, 1, defaultRBDPool) validateRBDImageCount(f, 1, defaultRBDPool)
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType) validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
for i := 0; i < snapChainDepth; i++ { for i := range snapChainDepth {
var pvcClone, smartClonePVC *v1.PersistentVolumeClaim var pvcClone, smartClonePVC *v1.PersistentVolumeClaim
snap := getSnapshot(snapshotPath) snap := getSnapshot(snapshotPath)
snap.Name = fmt.Sprintf("%s-%d", snap.Name, i) snap.Name = fmt.Sprintf("%s-%d", snap.Name, i)
@ -3722,7 +3722,7 @@ var _ = Describe("RBD", func() {
validateRBDImageCount(f, 1, defaultRBDPool) validateRBDImageCount(f, 1, defaultRBDPool)
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType) validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
for i := 0; i < cloneChainDepth; i++ { for i := range cloneChainDepth {
var pvcClone *v1.PersistentVolumeClaim var pvcClone *v1.PersistentVolumeClaim
pvcClone, err = loadPVC(pvcSmartClonePath) pvcClone, err = loadPVC(pvcSmartClonePath)
if err != nil { if err != nil {

View File

@ -377,7 +377,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot // create snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout) wgErrs[n] = createSnapshot(&s, deployTimeout)
@ -416,7 +416,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
pvcClone.Spec.DataSource.Name = fmt.Sprintf("%s%d", f.UniqueName, 0) pvcClone.Spec.DataSource.Name = fmt.Sprintf("%s%d", f.UniqueName, 0)
// create multiple PVCs from same snapshot // create multiple PVCs from same snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
@ -440,7 +440,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
} }
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -464,7 +464,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
wg.Add(totalCount) wg.Add(totalCount)
// delete snapshot // delete snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = deleteSnapshot(&s, deployTimeout) wgErrs[n] = deleteSnapshot(&s, deployTimeout)

View File

@ -927,7 +927,7 @@ func validatePVCClone(
appClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName
wg.Add(totalCount) wg.Add(totalCount)
// create clone and bind it to an app // create clone and bind it to an app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
label := make(map[string]string) label := make(map[string]string)
@ -1020,7 +1020,7 @@ func validatePVCClone(
validateRBDImageCount(f, totalCloneCount, defaultRBDPool) validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -1131,7 +1131,7 @@ func validatePVCSnapshot(
wg.Add(totalCount) wg.Add(totalCount)
// create snapshot // create snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout) wgErrs[n] = createSnapshot(&s, deployTimeout)
@ -1189,7 +1189,7 @@ func validatePVCSnapshot(
// create multiple PVC from same snapshot // create multiple PVC from same snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
label := make(map[string]string) label := make(map[string]string)
@ -1267,7 +1267,7 @@ func validatePVCSnapshot(
validateRBDImageCount(f, totalCloneCount, defaultRBDPool) validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -1294,7 +1294,7 @@ func validatePVCSnapshot(
// create clones from different snapshots and bind it to an // create clones from different snapshots and bind it to an
// app // app
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -1334,7 +1334,7 @@ func validatePVCSnapshot(
validateRBDImageCount(f, totalSnapCount, defaultRBDPool) validateRBDImageCount(f, totalSnapCount, defaultRBDPool)
wg.Add(totalCount) wg.Add(totalCount)
// delete snapshot // delete snapshot
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
content := &snapapi.VolumeSnapshotContent{} content := &snapapi.VolumeSnapshotContent{}
@ -1388,7 +1388,7 @@ func validatePVCSnapshot(
validateRBDImageCount(f, totalCount, defaultRBDPool) validateRBDImageCount(f, totalCount, defaultRBDPool)
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := range totalCount {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
@ -1814,7 +1814,7 @@ func checkExports(f *framework.Framework, clusterID, clientString string) bool {
} }
found := false found := false
for i := 0; i < len(*exportList); i++ { for i := range len(*exportList) {
export := (*exportList)[i] export := (*exportList)[i]
for _, client := range export.Clients { for _, client := range export.Clients {
for _, address := range client.Addresses { for _, address := range client.Addresses {

View File

@ -41,7 +41,7 @@ func TestFileChecker(t *testing.T) {
t.Error("checker failed to start") t.Error("checker failed to start")
} }
for i := 0; i < 10; i++ { for range 10 {
// check health, should be healthy // check health, should be healthy
healthy, msg := checker.isHealthy() healthy, msg := checker.isHealthy()
if !healthy || msg != nil { if !healthy || msg != nil {

View File

@ -41,11 +41,11 @@ func TestStatChecker(t *testing.T) {
t.Error("checker failed to start") t.Error("checker failed to start")
} }
for i := 0; i < 10; i++ { for i := range 10 {
// check health, should be healthy // check health, should be healthy
healthy, msg := checker.isHealthy() healthy, msg := checker.isHealthy()
if !healthy || msg != nil { if !healthy || msg != nil {
t.Error("volume is unhealthy") t.Errorf("volume is unhealthy after %d tries", i+1)
} }
time.Sleep(time.Second) time.Sleep(time.Second)

View File

@ -210,7 +210,7 @@ func findDeviceMappingImage(ctx context.Context, pool, namespace, image string,
// Stat a path, if it doesn't exist, retry maxRetries times. // Stat a path, if it doesn't exist, retry maxRetries times.
func waitForPath(ctx context.Context, pool, namespace, image string, maxRetries int, useNbdDriver bool) (string, bool) { func waitForPath(ctx context.Context, pool, namespace, image string, maxRetries int, useNbdDriver bool) (string, bool) {
for i := 0; i < maxRetries; i++ { for i := range maxRetries {
if i != 0 { if i != 0 {
time.Sleep(time.Second) time.Sleep(time.Second)
} }

View File

@ -249,7 +249,7 @@ func TestStrategicActionOnLogFile(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
var logFile [3]string var logFile [3]string
for i := 0; i < 3; i++ { for i := range 3 {
f, err := os.CreateTemp(tmpDir, "rbd-*.log") f, err := os.CreateTemp(tmpDir, "rbd-*.log")
if err != nil { if err != nil {
t.Errorf("creating tempfile failed: %v", err) t.Errorf("creating tempfile failed: %v", err)

View File

@ -244,7 +244,7 @@ func TestRTRemove(t *testing.T) {
"ref3": reftype.Normal, "ref3": reftype.Normal,
} }
for i := 0; i < 2; i++ { for range 2 {
created, err := Add(ioctx, rtName, refsToAdd) created, err := Add(ioctx, rtName, refsToAdd)
require.NoError(ts, err) require.NoError(ts, err)
require.True(ts, created) require.True(ts, created)