mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-23 03:54:23 +00:00
add -ignore-filename-pattern option
This commit is contained in:
parent
44710f9053
commit
f78b65b025
5 changed files with 50 additions and 17 deletions
|
|
@ -9,20 +9,21 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
ExitOnError bool
|
||||
Files []string
|
||||
SchemaLocations []string
|
||||
SkipTLS bool
|
||||
SkipKinds map[string]bool
|
||||
RejectKinds map[string]bool
|
||||
OutputFormat string
|
||||
KubernetesVersion string
|
||||
NumberOfWorkers int
|
||||
Summary bool
|
||||
Strict bool
|
||||
Verbose bool
|
||||
IgnoreMissingSchemas bool
|
||||
Help bool
|
||||
ExitOnError bool
|
||||
Files []string
|
||||
SchemaLocations []string
|
||||
SkipTLS bool
|
||||
SkipKinds map[string]bool
|
||||
RejectKinds map[string]bool
|
||||
OutputFormat string
|
||||
KubernetesVersion string
|
||||
NumberOfWorkers int
|
||||
Summary bool
|
||||
Strict bool
|
||||
Verbose bool
|
||||
IgnoreMissingSchemas bool
|
||||
IgnoreFilenamePatterns []string
|
||||
Help bool
|
||||
}
|
||||
|
||||
type arrayParam []string
|
||||
|
|
@ -50,7 +51,7 @@ func splitCSV(csvStr string) map[string]bool {
|
|||
}
|
||||
|
||||
func FromFlags(progName string, args []string) (Config, string, error) {
|
||||
var schemaLocationsParam arrayParam
|
||||
var schemaLocationsParam, ignoreFilenamePatterns arrayParam
|
||||
var skipKindsCSV, rejectKindsCSV string
|
||||
flags := flag.NewFlagSet(progName, flag.ExitOnError)
|
||||
var buf bytes.Buffer
|
||||
|
|
@ -65,6 +66,7 @@ func FromFlags(progName string, args []string) (Config, string, error) {
|
|||
flags.StringVar(&rejectKindsCSV, "reject", "", "comma-separated list of kinds to reject")
|
||||
flags.BoolVar(&c.ExitOnError, "exit-on-error", false, "immediately stop execution when the first error is encountered")
|
||||
flags.BoolVar(&c.IgnoreMissingSchemas, "ignore-missing-schemas", false, "skip files with missing schemas instead of failing")
|
||||
flags.Var(&ignoreFilenamePatterns, "ignore-filename-pattern", "regular expression specifying paths to ignore (can be specified multiple times)")
|
||||
flags.BoolVar(&c.Summary, "summary", false, "print a summary at the end")
|
||||
flags.IntVar(&c.NumberOfWorkers, "n", 4, "number of goroutines to run concurrently")
|
||||
flags.BoolVar(&c.Strict, "strict", false, "disallow additional properties not in schema")
|
||||
|
|
@ -83,6 +85,7 @@ func FromFlags(progName string, args []string) (Config, string, error) {
|
|||
|
||||
c.SkipKinds = splitCSV(skipKindsCSV)
|
||||
c.RejectKinds = splitCSV(rejectKindsCSV)
|
||||
c.IgnoreFilenamePatterns = ignoreFilenamePatterns
|
||||
c.SchemaLocations = schemaLocationsParam
|
||||
if len(c.SchemaLocations) == 0 {
|
||||
c.SchemaLocations = append(c.SchemaLocations, "https://kubernetesjsonschema.dev") // if not specified, default behaviour is to use kubernetesjson-schema.dev as registry
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue