Skip to content

Commit ad166c7

Browse files
authored
Sanitize csv strings (#258)
* Support spaces before/after commas when passing list of Kinds
1 parent a8000fd commit ad166c7

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func splitCSV(csvStr string) map[string]struct{} {
6363
valuesMap := map[string]struct{}{}
6464

6565
for _, kind := range splitValues {
66+
kind = strings.TrimSpace(kind)
6667
if len(kind) > 0 {
6768
valuesMap[kind] = struct{}{}
6869
}

pkg/config/config_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ func TestFromFlags(t *testing.T) {
9595
RejectKinds: map[string]struct{}{},
9696
},
9797
},
98+
{
99+
[]string{"-skip", "a, b, c"},
100+
Config{
101+
Files: []string{},
102+
KubernetesVersion: "master",
103+
NumberOfWorkers: 4,
104+
OutputFormat: "text",
105+
SchemaLocations: nil,
106+
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
107+
RejectKinds: map[string]struct{}{},
108+
},
109+
},
110+
{
111+
[]string{"-skip", "a,b, c"},
112+
Config{
113+
Files: []string{},
114+
KubernetesVersion: "master",
115+
NumberOfWorkers: 4,
116+
OutputFormat: "text",
117+
SchemaLocations: nil,
118+
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
119+
RejectKinds: map[string]struct{}{},
120+
},
121+
},
98122
{
99123
[]string{"-summary", "-verbose", "file1", "file2"},
100124
Config{

0 commit comments

Comments
 (0)