mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
cleanup: use slices package
This commit replaces the user implemented function `CheckSliceContains()` with `slices.Contains()` function introduced in Go 1.21. Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
parent
86a89d5425
commit
c1467242c6
@ -21,6 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -363,7 +364,7 @@ func attachRBDImage(ctx context.Context, volOptions *rbdVolume, device string, c
|
||||
}
|
||||
|
||||
func appendNbdDeviceTypeAndOptions(cmdArgs []string, userOptions, cookie string) []string {
|
||||
isUnmap := util.CheckSliceContains(cmdArgs, "unmap")
|
||||
isUnmap := slices.Contains(cmdArgs, "unmap")
|
||||
if !isUnmap {
|
||||
if !strings.Contains(userOptions, useNbdNetlink) {
|
||||
cmdArgs = append(cmdArgs, "--"+useNbdNetlink)
|
||||
|
@ -383,17 +383,6 @@ func CallStack() string {
|
||||
return string(stack)
|
||||
}
|
||||
|
||||
// CheckSliceContains checks the slice for string.
|
||||
func CheckSliceContains(options []string, opt string) bool {
|
||||
for _, o := range options {
|
||||
if o == opt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// GetVolumeContext filters out parameters that are not required in volume context.
|
||||
func GetVolumeContext(parameters map[string]string) map[string]string {
|
||||
volumeContext := map[string]string{}
|
||||
@ -403,7 +392,7 @@ func GetVolumeContext(parameters map[string]string) map[string]string {
|
||||
topologyPoolsParam,
|
||||
}
|
||||
for k, v := range parameters {
|
||||
if !CheckSliceContains(notRequiredParams, k) {
|
||||
if !slices.Contains(notRequiredParams, k) {
|
||||
volumeContext[k] = v
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user