Sanitize csv strings (#258)

* Support spaces before/after commas when passing list of Kinds
This commit is contained in:
PatDyn 2024-05-09 14:21:36 +02:00 committed by GitHub
parent a8000fd445
commit ad166c7f0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View file

@ -63,6 +63,7 @@ func splitCSV(csvStr string) map[string]struct{} {
valuesMap := map[string]struct{}{}
for _, kind := range splitValues {
kind = strings.TrimSpace(kind)
if len(kind) > 0 {
valuesMap[kind] = struct{}{}
}

View file

@ -95,6 +95,30 @@ func TestFromFlags(t *testing.T) {
RejectKinds: map[string]struct{}{},
},
},
{
[]string{"-skip", "a, b, c"},
Config{
Files: []string{},
KubernetesVersion: "master",
NumberOfWorkers: 4,
OutputFormat: "text",
SchemaLocations: nil,
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
RejectKinds: map[string]struct{}{},
},
},
{
[]string{"-skip", "a,b, c"},
Config{
Files: []string{},
KubernetesVersion: "master",
NumberOfWorkers: 4,
OutputFormat: "text",
SchemaLocations: nil,
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
RejectKinds: map[string]struct{}{},
},
},
{
[]string{"-summary", "-verbose", "file1", "file2"},
Config{