enhance: Trim space during parsing string list from string (#35546)

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
pull/35579/head
wei liu 2024-08-19 20:48:55 +08:00 committed by GitHub
parent 227ecd3901
commit 853d2f33e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import (
"strings"
"github.com/cockroachdb/errors"
"github.com/samber/lo"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
@ -286,7 +287,7 @@ func DatabaseLevelResourceGroups(kvs []*commonpb.KeyValuePair) ([]string, error)
return nil, invalidPropValue
}
return rgs, nil
return lo.Map(rgs, func(rg string, _ int) string { return strings.TrimSpace(rg) }), nil
}
}
@ -321,7 +322,7 @@ func CollectionLevelResourceGroups(kvs []*commonpb.KeyValuePair) ([]string, erro
return nil, invalidPropValue
}
return rgs, nil
return lo.Map(rgs, func(rg string, _ int) string { return strings.TrimSpace(rg) }), nil
}
}

View File

@ -22,6 +22,7 @@ import (
"strings"
"time"
"github.com/samber/lo"
"go.uber.org/atomic"
"github.com/milvus-io/milvus/pkg/config"
@ -335,7 +336,8 @@ func getAsStrings(v string) []string {
return []string{}
}
return getAndConvert(v, func(value string) ([]string, error) {
return strings.Split(value, ","), nil
ret := strings.Split(value, ",")
return lo.Map(ret, func(rg string, _ int) string { return strings.TrimSpace(rg) }), nil
}, []string{})
}