mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-22 19:27:01 +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
|
1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Validating mutiple files with a single flag
|
||||||
|
```bash
|
||||||
|
kubeconform fixtures/valid.yaml,fixtures/valid_version.yaml
|
||||||
|
```
|
||||||
|
|
||||||
* Passing manifests via Stdin
|
* Passing manifests via Stdin
|
||||||
```bash
|
```bash
|
||||||
cat fixtures/valid.yaml | ./bin/kubeconform -summary
|
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.RejectKinds = splitCSV(rejectKindsCSV)
|
||||||
c.IgnoreFilenamePatterns = ignoreFilenamePatterns
|
c.IgnoreFilenamePatterns = ignoreFilenamePatterns
|
||||||
c.SchemaLocations = schemaLocationsParam
|
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 {
|
if c.Help {
|
||||||
flags.Usage()
|
flags.Usage()
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,18 @@ func TestFromFlags(t *testing.T) {
|
||||||
Verbose: true,
|
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 {
|
for i, testCase := range testCases {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue