Config: Support JSON list syntax (#61288)

* Config: Separate lists either by spaces or by commas.

* Simplify space separation

* use separate function for the config strings

* Change behavior only if string contains quotes

* add test for invalid string

* Use JSON list syntax

* ignore leading spaces when process list

* Add notes about using JSON lists into the docs

* Fix typo

* Apply suggestions from code review

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
This commit is contained in:
Alexander Zobnin
2023-01-16 16:03:20 +03:00
committed by GitHub
co-authored by Christopher Moyer
parent 045a12047f
commit 997105c20d
5 changed files with 40 additions and 6 deletions
+11 -6
View File
@@ -46,12 +46,17 @@ func TestStringsFallback3(t *testing.T) {
func TestSplitString(t *testing.T) {
tests := map[string][]string{
"": {},
"test": {"test"},
"test1 test2 test3": {"test1", "test2", "test3"},
"test1,test2,test3": {"test1", "test2", "test3"},
"test1, test2, test3": {"test1", "test2", "test3"},
"test1 , test2 test3": {"test1", "test2", "test3"},
"": {},
"test": {"test"},
" test1 test2 test3": {"test1", "test2", "test3"},
"test1,test2,test3": {"test1", "test2", "test3"},
"test1, test2, test3": {"test1", "test2", "test3"},
"test1 , test2 test3": {"test1", "test2", "test3"},
"foo, bar baz": {"foo", "bar", "baz"},
`["foo", "bar baz"]`: {"foo", "bar baz"},
`["foo", "bar \"baz\""]`: {"foo", "bar \"baz\""},
` ["foo", "bar baz"]`: {"foo", "bar baz"},
`[]`: {},
}
for input, expected := range tests {
assert.EqualValues(t, expected, SplitString(input))