From 9ee3c5f07f4cf984ac7e8c433ddefbdbf2bdfd25 Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Sun, 1 Nov 2020 16:43:25 +0100 Subject: [PATCH] Do not validate when no schema given --- cmd/kubeconform/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/kubeconform/main.go b/cmd/kubeconform/main.go index fd97338..d38d635 100644 --- a/cmd/kubeconform/main.go +++ b/cmd/kubeconform/main.go @@ -55,18 +55,17 @@ func ValidateResources(resources <-chan []resource.Resource, validationResults c continue } - ok := false + cached := false var schema *gojsonschema.Schema cacheKey := "" if c != nil { cacheKey = cache.Key(sig.Kind, sig.Version, k8sVersion) - schema, ok = c.Get(cacheKey) + schema, cached = c.Get(cacheKey) } - if !ok { - schema, err = downloadSchema(regs, sig.Kind, sig.Version, k8sVersion) - if err != nil { + if !cached { + if schema, err = downloadSchema(regs, sig.Kind, sig.Version, k8sVersion); err != nil { validationResults <- validator.Result{Resource: res, Err: err, Status: validator.Error} continue } @@ -82,6 +81,7 @@ func ValidateResources(resources <-chan []resource.Resource, validationResults c } else { validationResults <- validator.Result{Resource: res, Err: fmt.Errorf("could not find schema for %s", sig.Kind), Status: validator.Error} } + continue } validationResults <- validator.Validate(res, schema)