diff --git a/Readme.md b/Readme.md index dbffd67..0f03535 100644 --- a/Readme.md +++ b/Readme.md @@ -165,6 +165,11 @@ $ echo $? 1 ``` +* Validating mutiple files with a single flag +```bash +kubeconform fixtures/valid.yaml,fixtures/valid_version.yaml +``` + * Passing manifests via Stdin ```bash cat fixtures/valid.yaml | ./bin/kubeconform -summary diff --git a/pkg/config/config.go b/pkg/config/config.go index b64a3c1..6ae4f8b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -91,7 +91,14 @@ func FromFlags(progName string, args []string) (Config, string, error) { c.RejectKinds = splitCSV(rejectKindsCSV) c.IgnoreFilenamePatterns = ignoreFilenamePatterns c.SchemaLocations = schemaLocationsParam - c.Files = flags.Args() + files := flags.Args() + for _, file := range files { + if strings.Contains(file, ",") { + c.Files = append(c.Files, strings.Split(file, ",")...) + } else { + c.Files = append(c.Files, file) + } + } if c.Help { flags.Usage() diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 9a184d5..f053a21 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -129,6 +129,18 @@ func TestFromFlags(t *testing.T) { Verbose: true, }, }, + { + []string{"file1,file2,file3"}, + Config{ + Files: []string{"file1", "file2", "file3"}, + KubernetesVersion: "master", + NumberOfWorkers: 4, + OutputFormat: "text", + SchemaLocations: nil, + SkipKinds: map[string]struct{}{}, + RejectKinds: map[string]struct{}{}, + }, + }, } for i, testCase := range testCases {