@@ -33,6 +33,7 @@ import (
33
33
"k8s.io/apimachinery/pkg/api/equality"
34
34
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35
35
"k8s.io/utils/pointer"
36
+ "slices"
36
37
)
37
38
38
39
// +kubebuilder:object:root=true
@@ -1799,7 +1800,7 @@ func (str *ConnectionString) String() string {
1799
1800
// GenerateNewGenerationID builds a new generation ID
1800
1801
func (str * ConnectionString ) GenerateNewGenerationID () error {
1801
1802
id := strings.Builder {}
1802
- for i := 0 ; i < 32 ; i ++ {
1803
+ for range 32 {
1803
1804
err := id .WriteByte (alphanum [rand .Intn (len (alphanum ))])
1804
1805
if err != nil {
1805
1806
return err
@@ -2022,19 +2023,11 @@ func (cluster *FoundationDBCluster) ProcessGroupIsBeingRemoved(processGroupID Pr
2022
2023
}
2023
2024
}
2024
2025
2025
- for _ , id := range cluster .Spec .ProcessGroupsToRemove {
2026
- if id == processGroupID {
2027
- return true
2028
- }
2029
- }
2030
-
2031
- for _ , id := range cluster .Spec .ProcessGroupsToRemoveWithoutExclusion {
2032
- if id == processGroupID {
2033
- return true
2034
- }
2026
+ if slices .Contains (cluster .Spec .ProcessGroupsToRemove , processGroupID ) {
2027
+ return true
2035
2028
}
2036
2029
2037
- return false
2030
+ return slices . Contains ( cluster . Spec . ProcessGroupsToRemoveWithoutExclusion , processGroupID )
2038
2031
}
2039
2032
2040
2033
// ShouldUseLocks determine whether we should use locks to coordinator global
@@ -2262,20 +2255,16 @@ const (
2262
2255
// AddServersPerDisk adds serverPerDisk to the status field to keep track which ConfigMaps should be kept
2263
2256
func (clusterStatus * FoundationDBClusterStatus ) AddServersPerDisk (serversPerDisk int , pClass ProcessClass ) {
2264
2257
if pClass == ProcessClassStorage {
2265
- for _ , curServersPerDisk := range clusterStatus .StorageServersPerDisk {
2266
- if curServersPerDisk == serversPerDisk {
2267
- return
2268
- }
2258
+ if slices .Contains (clusterStatus .StorageServersPerDisk , serversPerDisk ) {
2259
+ return
2269
2260
}
2270
2261
clusterStatus .StorageServersPerDisk = append (clusterStatus .StorageServersPerDisk , serversPerDisk )
2271
2262
return
2272
2263
}
2273
2264
2274
2265
if pClass .SupportsMultipleLogServers () {
2275
- for _ , curServersPerDisk := range clusterStatus .LogServersPerDisk {
2276
- if curServersPerDisk == serversPerDisk {
2277
- return
2278
- }
2266
+ if slices .Contains (clusterStatus .LogServersPerDisk , serversPerDisk ) {
2267
+ return
2279
2268
}
2280
2269
clusterStatus .LogServersPerDisk = append (clusterStatus .LogServersPerDisk , serversPerDisk )
2281
2270
}
0 commit comments