mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-22 19:27:01 +00:00
add -insecure-skip-tls-verify
This commit is contained in:
parent
b162c5b6f5
commit
ec56304efd
5 changed files with 13 additions and 4 deletions
|
|
@ -53,6 +53,8 @@ Usage: ./bin/kubeconform [OPTION]... [FILE OR FOLDER]...
|
||||||
-h show help information
|
-h show help information
|
||||||
-ignore-missing-schemas
|
-ignore-missing-schemas
|
||||||
skip files with missing schemas instead of failing
|
skip files with missing schemas instead of failing
|
||||||
|
-insecure-skip-tls-verify
|
||||||
|
disable verification of the server's SSL certificate. This will make your HTTPS connections insecure
|
||||||
-kubernetes-version string
|
-kubernetes-version string
|
||||||
version of Kubernetes to validate against (default "1.18.0")
|
version of Kubernetes to validate against (default "1.18.0")
|
||||||
-n int
|
-n int
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ func realMain() int {
|
||||||
|
|
||||||
registries := []registry.Registry{}
|
registries := []registry.Registry{}
|
||||||
for _, schemaLocation := range cfg.SchemaLocations {
|
for _, schemaLocation := range cfg.SchemaLocations {
|
||||||
registries = append(registries, registry.New(schemaLocation, cfg.Strict))
|
registries = append(registries, registry.New(schemaLocation, cfg.Strict, cfg.SkipTLS))
|
||||||
}
|
}
|
||||||
|
|
||||||
var o output.Output
|
var o output.Output
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ type Config struct {
|
||||||
ExitOnError bool
|
ExitOnError bool
|
||||||
Files []string
|
Files []string
|
||||||
SchemaLocations []string
|
SchemaLocations []string
|
||||||
|
SkipTLS bool
|
||||||
SkipKinds map[string]bool
|
SkipKinds map[string]bool
|
||||||
RejectKinds map[string]bool
|
RejectKinds map[string]bool
|
||||||
OutputFormat string
|
OutputFormat string
|
||||||
|
|
@ -69,6 +70,7 @@ func FromFlags(progName string, args []string) (Config, string, error) {
|
||||||
flags.BoolVar(&c.Strict, "strict", false, "disallow additional properties not in schema")
|
flags.BoolVar(&c.Strict, "strict", false, "disallow additional properties not in schema")
|
||||||
flags.StringVar(&c.OutputFormat, "output", "text", "output format - text, json")
|
flags.StringVar(&c.OutputFormat, "output", "text", "output format - text, json")
|
||||||
flags.BoolVar(&c.Verbose, "verbose", false, "print results for all resources")
|
flags.BoolVar(&c.Verbose, "verbose", false, "print results for all resources")
|
||||||
|
flags.BoolVar(&c.SkipTLS, "insecure-skip-tls-verify", false, "disable verification of the server's SSL certificate. This will make your HTTPS connections insecure")
|
||||||
flags.BoolVar(&c.Help, "h", false, "show help information")
|
flags.BoolVar(&c.Help, "h", false, "show help information")
|
||||||
flags.Usage = func() {
|
flags.Usage = func() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE OR FOLDER]...\n", progName)
|
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE OR FOLDER]...\n", progName)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -22,7 +23,11 @@ func newDownloadError(err error, isRetryable bool) *downloadError {
|
||||||
func (e *downloadError) IsRetryable() bool { return e.isRetryable }
|
func (e *downloadError) IsRetryable() bool { return e.isRetryable }
|
||||||
func (e *downloadError) Error() string { return e.err.Error() }
|
func (e *downloadError) Error() string { return e.err.Error() }
|
||||||
|
|
||||||
func newHTTPRegistry(schemaPathTemplate string, strict bool) *KubernetesRegistry {
|
func newHTTPRegistry(schemaPathTemplate string, strict bool, skipTLS bool) *KubernetesRegistry {
|
||||||
|
if skipTLS {
|
||||||
|
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
}
|
||||||
|
|
||||||
return &KubernetesRegistry{
|
return &KubernetesRegistry{
|
||||||
schemaPathTemplate: schemaPathTemplate,
|
schemaPathTemplate: schemaPathTemplate,
|
||||||
strict: strict,
|
strict: strict,
|
||||||
|
|
|
||||||
|
|
@ -65,13 +65,13 @@ func schemaPath(tpl, resourceKind, resourceAPIVersion, k8sVersion string, strict
|
||||||
return buf.String(), nil
|
return buf.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(schemaLocation string, strict bool) Registry {
|
func New(schemaLocation string, strict bool, skipTLS bool) Registry {
|
||||||
if !strings.HasSuffix(schemaLocation, "json") { // If we dont specify a full templated path, we assume the paths of kubernetesjsonschema.dev
|
if !strings.HasSuffix(schemaLocation, "json") { // If we dont specify a full templated path, we assume the paths of kubernetesjsonschema.dev
|
||||||
schemaLocation += "/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json"
|
schemaLocation += "/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(schemaLocation, "http") {
|
if strings.HasPrefix(schemaLocation, "http") {
|
||||||
return newHTTPRegistry(schemaLocation, strict)
|
return newHTTPRegistry(schemaLocation, strict, skipTLS)
|
||||||
} else {
|
} else {
|
||||||
return newLocalRegistry(schemaLocation, strict)
|
return newLocalRegistry(schemaLocation, strict)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue