From 93d9967adaddc2fc4ae0167f29a358dc3f6c3792 Mon Sep 17 00:00:00 2001 From: Ruslan Aliev Date: Wed, 12 May 2021 17:40:30 -0500 Subject: [PATCH] Add possibility to override default schema location for validator This feature would be helpful in case if default schema location is not reachable (e.g. proxy restrictions). Change-Id: I9a36256410b31bf5de410fab88cc2c3f31ed5793 Signed-off-by: Ruslan Aliev --- krm-functions/kubeval-validator/image/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/krm-functions/kubeval-validator/image/main.go b/krm-functions/kubeval-validator/image/main.go index 2075ea10b..9de47272c 100644 --- a/krm-functions/kubeval-validator/image/main.go +++ b/krm-functions/kubeval-validator/image/main.go @@ -97,6 +97,10 @@ type Spec struct { // KubernetesVersion is the version of Kubernetes to validate // against (default "master"). KubernetesVersion string `yaml:"kubernetesVersion,omitempty"` + + // SchemaLocation is the base URL from which to search for schemas. + // It can be either a remote location or a local directory + SchemaLocation string `yaml:"schemaLocation,omitempty"` } // CRDSpec holds special options for plan/phase which kinds to skip and which additional CRDs to include @@ -125,6 +129,7 @@ func (f kubevalFilter) Filter(in []*yaml.RNode) ([]*yaml.RNode, error) { kubevalConfig.Strict = cfg.Spec.Strict kubevalConfig.IgnoreMissingSchemas = cfg.Spec.IgnoreMissingSchemas kubevalConfig.KubernetesVersion = cfg.Spec.KubernetesVersion + kubevalConfig.SchemaLocation = cfg.Spec.SchemaLocation kubevalConfig.AdditionalSchemaLocations = []string{fileScheme + "://" + schemaLocationDir} kubevalConfig.KindsToSkip = []string{crdKind, kubevalOptsKind} var crdList []string