mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-15 16:59:51 +00:00
add -dir parameter
This commit is contained in:
parent
81aca53a84
commit
2786a84a4c
5 changed files with 84 additions and 30 deletions
32
pkg/fsutils/main.go
Normal file
32
pkg/fsutils/main.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package fsutils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func FindYamlInDir(dir string, fileBatches chan<- []string, batchSize int) error {
|
||||
files := []string{}
|
||||
|
||||
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !info.IsDir() && (strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) {
|
||||
files = append(files, path)
|
||||
if len(files) > batchSize {
|
||||
fileBatches <- files
|
||||
files = nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if len(files) > 0 {
|
||||
fileBatches <- files
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
@ -18,12 +18,13 @@ func (f ValidFormat) IsFormat(input interface{}) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func init () {
|
||||
gojsonschema.FormatCheckers.Add("int64", ValidFormat{})
|
||||
gojsonschema.FormatCheckers.Add("byte", ValidFormat{})
|
||||
gojsonschema.FormatCheckers.Add("int32", ValidFormat{})
|
||||
gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
|
||||
}
|
||||
// From kubeval - let's see if absolutely necessary
|
||||
// func init () {
|
||||
// gojsonschema.FormatCheckers.Add("int64", ValidFormat{})
|
||||
// gojsonschema.FormatCheckers.Add("byte", ValidFormat{})
|
||||
// gojsonschema.FormatCheckers.Add("int32", ValidFormat{})
|
||||
// gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
|
||||
// }
|
||||
|
||||
func Validate(rawResource []byte, rawSchema []byte) error {
|
||||
schemaLoader := gojsonschema.NewBytesLoader(rawSchema)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue