Skip to content

Commit

Permalink
Sanitize csv strings (#258)
Browse files Browse the repository at this point in the history
* Support spaces before/after commas when passing list of Kinds
  • Loading branch information
PatDyn authored May 9, 2024
1 parent a8000fd commit ad166c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}
Expand Down
24 changes: 24 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit ad166c7

Please sign in to comment.