From 795cc54679c3d1cbdeec8350b0ef312fb68671b2 Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Sun, 31 May 2020 20:03:50 +0200 Subject: [PATCH] make logic more explicit --- main.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 447fb7a..9224c8f 100644 --- a/main.go +++ b/main.go @@ -91,18 +91,17 @@ func validateFile(r io.Reader, regs []registry.Registry, k8sVersion string, c *c cacheKey := cache.Key(sig.Kind, sig.Version, k8sVersion) schema, ok := c.Get(cacheKey) if !ok { - if schema, err = downloadSchema(regs, sig.Kind, sig.Version, k8sVersion); err != nil { + schema, err = downloadSchema(regs, sig.Kind, sig.Version, k8sVersion) + if err != nil { validationResults = append(validationResults, validationResult{kind: sig.Kind, version: sig.Version, err: err, skipped: false}) continue - } - - if schema == nil { - validationResults = append(validationResults, validationResult{kind: sig.Kind, version: sig.Version, err: nil, skipped: true}) // skip if no schema found + } else if schema == nil { // skip if no schema was found, but there was no error + validationResults = append(validationResults, validationResult{kind: sig.Kind, version: sig.Version, err: nil, skipped: true}) c.Set(cacheKey, nil) continue + } else { + c.Set(cacheKey, schema) } - - c.Set(cacheKey, schema) } if err = validator.Validate(rawResource, schema); err != nil {