mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-17 08:57:02 +00:00
Merge 31c3c42c9d into e60892483e
This commit is contained in:
commit
770d0c4496
1 changed files with 17 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
@ -75,7 +76,7 @@ func splitCSV(csvStr string) map[string]struct{} {
|
||||||
// FromFlags retrieves kubeconform's runtime configuration from the command-line parameters
|
// FromFlags retrieves kubeconform's runtime configuration from the command-line parameters
|
||||||
func FromFlags(progName string, args []string) (Config, string, error) {
|
func FromFlags(progName string, args []string) (Config, string, error) {
|
||||||
var schemaLocationsParam, ignoreFilenamePatterns arrayParam
|
var schemaLocationsParam, ignoreFilenamePatterns arrayParam
|
||||||
var skipKindsCSV, rejectKindsCSV string
|
var skipKindsCSV, rejectKindsCSV, envSchemaLocation string
|
||||||
flags := flag.NewFlagSet(progName, flag.ContinueOnError)
|
flags := flag.NewFlagSet(progName, flag.ContinueOnError)
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
flags.SetOutput(&buf)
|
flags.SetOutput(&buf)
|
||||||
|
|
@ -113,6 +114,21 @@ func FromFlags(progName string, args []string) (Config, string, error) {
|
||||||
c.SchemaLocations = schemaLocationsParam
|
c.SchemaLocations = schemaLocationsParam
|
||||||
c.Files = flags.Args()
|
c.Files = flags.Args()
|
||||||
|
|
||||||
|
envSchemaLocation, _ = os.LookupEnv("KUBECONFORM_SCHEMA_LOCATION")
|
||||||
|
if envSchemaLocation != "" {
|
||||||
|
var kubeconformSchemaLocation []string
|
||||||
|
kubeconformSchemaLocation = strings.Split(envSchemaLocation, ",")
|
||||||
|
for _, s := range kubeconformSchemaLocation {
|
||||||
|
c.SchemaLocations = append(c.SchemaLocations, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Verbose == true {
|
||||||
|
for i, s := range c.SchemaLocations {
|
||||||
|
fmt.Printf("Schema location %d: %s\n", i, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if c.Help {
|
if c.Help {
|
||||||
flags.Usage()
|
flags.Usage()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue