mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-18 17:37:03 +00:00
feat: support passing mutiple files in a single flag
This commit is contained in:
parent
84afe70659
commit
5419a5ead4
3 changed files with 25 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue