mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
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:
parent
0e7b06e9d0
commit
e85914fc0d
@ -874,7 +874,7 @@ var _ = Describe(cephfsType, func() {
|
||||
}
|
||||
app.Namespace = f.UniqueName
|
||||
// create PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err = createPVCAndApp(name, f, pvc, app, deployTimeout)
|
||||
if err != nil {
|
||||
@ -889,7 +889,7 @@ var _ = Describe(cephfsType, func() {
|
||||
validateSubvolumeCount(f, totalCount, fileSystemName, subvolumegroup)
|
||||
validateOmapCount(f, totalCount, cephfsType, metadataPool, volumesType)
|
||||
// delete PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err = deletePVCAndApp(name, f, pvc, app)
|
||||
if err != nil {
|
||||
@ -1452,7 +1452,7 @@ var _ = Describe(cephfsType, func() {
|
||||
snap.Namespace = f.UniqueName
|
||||
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
||||
// create snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createSnapshot(&s, deployTimeout)
|
||||
@ -1488,7 +1488,7 @@ var _ = Describe(cephfsType, func() {
|
||||
|
||||
// create multiple PVC from same snapshot
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||
@ -1520,7 +1520,7 @@ var _ = Describe(cephfsType, func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -1548,7 +1548,7 @@ var _ = Describe(cephfsType, func() {
|
||||
// create clones from different snapshots and bind it to an
|
||||
// app
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -1581,7 +1581,7 @@ var _ = Describe(cephfsType, func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
|
||||
@ -1605,7 +1605,7 @@ var _ = Describe(cephfsType, func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -2308,7 +2308,7 @@ var _ = Describe(cephfsType, func() {
|
||||
appClone.Namespace = f.UniqueName
|
||||
wg.Add(totalCount)
|
||||
// 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) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||
@ -2340,7 +2340,7 @@ var _ = Describe(cephfsType, func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
|
20
e2e/nfs.go
20
e2e/nfs.go
@ -528,7 +528,7 @@ var _ = Describe("nfs", func() {
|
||||
}
|
||||
app.Namespace = f.UniqueName
|
||||
// create PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err = createPVCAndApp(name, f, pvc, app, deployTimeout)
|
||||
if err != nil {
|
||||
@ -542,7 +542,7 @@ var _ = Describe("nfs", func() {
|
||||
|
||||
validateSubvolumeCount(f, totalCount, fileSystemName, defaultSubvolumegroup)
|
||||
// delete PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err = deletePVCAndApp(name, f, pvc, app)
|
||||
if err != nil {
|
||||
@ -699,7 +699,7 @@ var _ = Describe("nfs", func() {
|
||||
snap.Namespace = f.UniqueName
|
||||
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
||||
// create snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createSnapshot(&s, deployTimeout)
|
||||
@ -736,7 +736,7 @@ var _ = Describe("nfs", func() {
|
||||
|
||||
// create multiple PVC from same snapshot
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||
@ -790,7 +790,7 @@ var _ = Describe("nfs", func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -817,7 +817,7 @@ var _ = Describe("nfs", func() {
|
||||
validateOmapCount(f, totalCount, cephfsType, metadataPool, snapsType)
|
||||
// create clones from different snapshots and bind it to an app
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -872,7 +872,7 @@ var _ = Describe("nfs", func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
|
||||
@ -896,7 +896,7 @@ var _ = Describe("nfs", func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -980,7 +980,7 @@ var _ = Describe("nfs", func() {
|
||||
appClone.Labels = label
|
||||
wg.Add(totalCount)
|
||||
// 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) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||
@ -1036,7 +1036,7 @@ var _ = Describe("nfs", func() {
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
|
14
e2e/rbd.go
14
e2e/rbd.go
@ -2721,7 +2721,7 @@ var _ = Describe("RBD", func() {
|
||||
}
|
||||
app.Namespace = f.UniqueName
|
||||
// create PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err := createPVCAndApp(name, f, pvc, app, deployTimeout)
|
||||
if err != nil {
|
||||
@ -2733,7 +2733,7 @@ var _ = Describe("RBD", func() {
|
||||
validateRBDImageCount(f, totalCount, defaultRBDPool)
|
||||
validateOmapCount(f, totalCount, rbdType, defaultRBDPool, volumesType)
|
||||
// delete PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err := deletePVCAndApp(name, f, pvc, app)
|
||||
if err != nil {
|
||||
@ -3316,7 +3316,7 @@ var _ = Describe("RBD", func() {
|
||||
appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
||||
|
||||
// create PVC and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
label := map[string]string{
|
||||
"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)
|
||||
opt := metav1.ListOptions{
|
||||
LabelSelector: "app=" + name,
|
||||
@ -3348,7 +3348,7 @@ var _ = Describe("RBD", func() {
|
||||
}
|
||||
|
||||
// delete app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
appClone.Name = name
|
||||
err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout)
|
||||
@ -3552,7 +3552,7 @@ var _ = Describe("RBD", func() {
|
||||
// validate created backend rbd images
|
||||
validateRBDImageCount(f, 1, defaultRBDPool)
|
||||
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
||||
for i := 0; i < snapChainDepth; i++ {
|
||||
for i := range snapChainDepth {
|
||||
var pvcClone, smartClonePVC *v1.PersistentVolumeClaim
|
||||
snap := getSnapshot(snapshotPath)
|
||||
snap.Name = fmt.Sprintf("%s-%d", snap.Name, i)
|
||||
@ -3722,7 +3722,7 @@ var _ = Describe("RBD", func() {
|
||||
validateRBDImageCount(f, 1, defaultRBDPool)
|
||||
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
||||
|
||||
for i := 0; i < cloneChainDepth; i++ {
|
||||
for i := range cloneChainDepth {
|
||||
var pvcClone *v1.PersistentVolumeClaim
|
||||
pvcClone, err = loadPVC(pvcSmartClonePath)
|
||||
if err != nil {
|
||||
|
@ -377,7 +377,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
|
||||
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
||||
// create snapshot
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
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)
|
||||
// create multiple PVCs from same snapshot
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||
@ -440,7 +440,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
|
||||
}
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -464,7 +464,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
|
||||
|
||||
wg.Add(totalCount)
|
||||
// delete snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
|
||||
|
18
e2e/utils.go
18
e2e/utils.go
@ -927,7 +927,7 @@ func validatePVCClone(
|
||||
appClone.Namespace = f.UniqueName
|
||||
wg.Add(totalCount)
|
||||
// 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) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
label := make(map[string]string)
|
||||
@ -1020,7 +1020,7 @@ func validatePVCClone(
|
||||
validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -1131,7 +1131,7 @@ func validatePVCSnapshot(
|
||||
|
||||
wg.Add(totalCount)
|
||||
// create snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
wgErrs[n] = createSnapshot(&s, deployTimeout)
|
||||
@ -1189,7 +1189,7 @@ func validatePVCSnapshot(
|
||||
|
||||
// create multiple PVC from same snapshot
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
label := make(map[string]string)
|
||||
@ -1267,7 +1267,7 @@ func validatePVCSnapshot(
|
||||
validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -1294,7 +1294,7 @@ func validatePVCSnapshot(
|
||||
// create clones from different snapshots and bind it to an
|
||||
// app
|
||||
wg.Add(totalCount)
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -1334,7 +1334,7 @@ func validatePVCSnapshot(
|
||||
validateRBDImageCount(f, totalSnapCount, defaultRBDPool)
|
||||
wg.Add(totalCount)
|
||||
// delete snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, s snapapi.VolumeSnapshot) {
|
||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
content := &snapapi.VolumeSnapshotContent{}
|
||||
@ -1388,7 +1388,7 @@ func validatePVCSnapshot(
|
||||
validateRBDImageCount(f, totalCount, defaultRBDPool)
|
||||
wg.Add(totalCount)
|
||||
// delete clone and app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
for i := range totalCount {
|
||||
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||
p.Spec.DataSource.Name = name
|
||||
@ -1814,7 +1814,7 @@ func checkExports(f *framework.Framework, clusterID, clientString string) bool {
|
||||
}
|
||||
|
||||
found := false
|
||||
for i := 0; i < len(*exportList); i++ {
|
||||
for i := range len(*exportList) {
|
||||
export := (*exportList)[i]
|
||||
for _, client := range export.Clients {
|
||||
for _, address := range client.Addresses {
|
||||
|
@ -41,7 +41,7 @@ func TestFileChecker(t *testing.T) {
|
||||
t.Error("checker failed to start")
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
// check health, should be healthy
|
||||
healthy, msg := checker.isHealthy()
|
||||
if !healthy || msg != nil {
|
||||
|
@ -41,11 +41,11 @@ func TestStatChecker(t *testing.T) {
|
||||
t.Error("checker failed to start")
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
for i := range 10 {
|
||||
// check health, should be healthy
|
||||
healthy, msg := checker.isHealthy()
|
||||
if !healthy || msg != nil {
|
||||
t.Error("volume is unhealthy")
|
||||
t.Errorf("volume is unhealthy after %d tries", i+1)
|
||||
}
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
@ -210,7 +210,7 @@ func findDeviceMappingImage(ctx context.Context, pool, namespace, image string,
|
||||
|
||||
// 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) {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
for i := range maxRetries {
|
||||
if i != 0 {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ func TestStrategicActionOnLogFile(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
var logFile [3]string
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := range 3 {
|
||||
f, err := os.CreateTemp(tmpDir, "rbd-*.log")
|
||||
if err != nil {
|
||||
t.Errorf("creating tempfile failed: %v", err)
|
||||
|
@ -244,7 +244,7 @@ func TestRTRemove(t *testing.T) {
|
||||
"ref3": reftype.Normal,
|
||||
}
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
for range 2 {
|
||||
created, err := Add(ioctx, rtName, refsToAdd)
|
||||
require.NoError(ts, err)
|
||||
require.True(ts, created)
|
||||
|
Loading…
Reference in New Issue
Block a user