mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
Sanitize csv strings (#258)
* Support spaces before/after commas when passing list of Kinds
This commit is contained in:
parent
a8000fd445
commit
ad166c7f0d
2 changed files with 25 additions and 0 deletions
|
|
@ -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{}{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Reference in a new issue