mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-19 09:57:02 +00:00
refactor: expose kubeconform config
This commit is contained in:
parent
484252d280
commit
336abefd7c
1 changed files with 39 additions and 25 deletions
|
|
@ -16,27 +16,48 @@ type Stream struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Cache string
|
Cache string `yaml:"cache" json:"cache"`
|
||||||
Debug bool
|
Debug bool `yaml:"debug" json:"debug"`
|
||||||
ExitOnError bool
|
ExitOnError bool `yaml:"exitOnError" json:"exitOnError"`
|
||||||
Files []string
|
Files []string `yaml:"files" json:"files"`
|
||||||
SchemaLocations []string
|
Help bool `yaml:"help" json:"help"`
|
||||||
SkipTLS bool
|
IgnoreFilenamePatterns []string `yaml:"ignoreFilenamePatterns" json:"ignoreFilenamePatterns"`
|
||||||
SkipKinds map[string]struct{}
|
IgnoreMissingSchemas bool `yaml:"ignoreMissingSchemas" json:"ignoreMissingSchemas"`
|
||||||
|
KubernetesVersion string `yaml:"kubernetesVersion" json:"kubernetesVersion"`
|
||||||
|
NumberOfWorkers int `yaml:"numberOfWorkers" json:"numberOfWorkers"`
|
||||||
|
OutputFormat string `yaml:"output" json:"output"`
|
||||||
RejectKinds map[string]struct{}
|
RejectKinds map[string]struct{}
|
||||||
OutputFormat string
|
RejectKindsNG []string `yaml:"reject" json:"reject"`
|
||||||
KubernetesVersion string
|
SchemaLocations []string `yaml:"schemaLocations" json:"schemaLocations"`
|
||||||
NumberOfWorkers int
|
SkipKinds map[string]struct{}
|
||||||
Summary bool
|
SkipKindsNG []string `yaml:"skip" json:"skip"`
|
||||||
Strict bool
|
SkipTLS bool `yaml:"insecureSkipTLSVerify" json:"insecureSkipTLSVerify"`
|
||||||
Verbose bool
|
Strict bool `yaml:"strict" json:"strict"`
|
||||||
IgnoreMissingSchemas bool
|
Summary bool `yaml:"summary" json:"summary"`
|
||||||
IgnoreFilenamePatterns []string
|
Verbose bool `yaml:"verbose" json:"verbose"`
|
||||||
Help bool
|
Version bool `yaml:"version" json:"version"`
|
||||||
Version bool
|
|
||||||
Stream *Stream
|
Stream *Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadNGConfig allows to introduce new config format/structure while keeping backward compatibility.
|
||||||
|
func (c *Config) LoadNGConfig() error {
|
||||||
|
// SkipKindsNG.
|
||||||
|
loadKinds(c.SkipKinds, c.SkipKindsNG)
|
||||||
|
|
||||||
|
// RejectKindsNG.
|
||||||
|
loadKinds(c.RejectKinds, c.RejectKindsNG)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadKinds(dest map[string]struct{}, src []string) {
|
||||||
|
for _, kind := range src {
|
||||||
|
if len(kind) > 0 {
|
||||||
|
dest[kind] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type arrayParam []string
|
type arrayParam []string
|
||||||
|
|
||||||
func (ap *arrayParam) String() string {
|
func (ap *arrayParam) String() string {
|
||||||
|
|
@ -49,15 +70,8 @@ func (ap *arrayParam) Set(value string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitCSV(csvStr string) map[string]struct{} {
|
func splitCSV(csvStr string) map[string]struct{} {
|
||||||
splitValues := strings.Split(csvStr, ",")
|
|
||||||
valuesMap := map[string]struct{}{}
|
valuesMap := map[string]struct{}{}
|
||||||
|
loadKinds(valuesMap, strings.Split(csvStr, ","))
|
||||||
for _, kind := range splitValues {
|
|
||||||
if len(kind) > 0 {
|
|
||||||
valuesMap[kind] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return valuesMap
|
return valuesMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue