This commit is contained in:
Redacid 2025-10-13 13:10:08 +02:00 committed by GitHub
commit 770d0c4496
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@ import (
"bytes"
"flag"
"fmt"
"os"
"regexp"
"strings"
)
@ -75,7 +76,7 @@ func splitCSV(csvStr string) map[string]struct{} {
// FromFlags retrieves kubeconform's runtime configuration from the command-line parameters
func FromFlags(progName string, args []string) (Config, string, error) {
var schemaLocationsParam, ignoreFilenamePatterns arrayParam
var skipKindsCSV, rejectKindsCSV string
var skipKindsCSV, rejectKindsCSV, envSchemaLocation string
flags := flag.NewFlagSet(progName, flag.ContinueOnError)
var buf bytes.Buffer
flags.SetOutput(&buf)
@ -113,6 +114,21 @@ func FromFlags(progName string, args []string) (Config, string, error) {
c.SchemaLocations = schemaLocationsParam
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 {
flags.Usage()
}