replace strings.SplitN with strings.Cut

Signed-off-by: Amir M. Ghazanfari <a.m.ghazanfari76@gmail.com>
This commit is contained in:
Amir M. Ghazanfari
2024-09-28 10:02:21 +03:30
parent 15904913c2
commit faffe1b9ee
5 changed files with 18 additions and 20 deletions

View File

@@ -101,14 +101,14 @@ func SearchLabels(labels []string, key string) (string, bool) {
func Annotations(labels []string) (bundle string, userAnnotations map[string]string) {
userAnnotations = make(map[string]string)
for _, l := range labels {
parts := strings.SplitN(l, "=", 2)
if len(parts) < 2 {
name, value, ok := strings.Cut(l, "=")
if !ok {
continue
}
if parts[0] == "bundle" {
bundle = parts[1]
if name == "bundle" {
bundle = value
} else {
userAnnotations[parts[0]] = parts[1]
userAnnotations[name] = value
}
}
return