mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-19 18:07:02 +00:00
make logic more explicit
This commit is contained in:
parent
ed0ca92439
commit
795cc54679
1 changed files with 6 additions and 7 deletions
13
main.go
13
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)
|
cacheKey := cache.Key(sig.Kind, sig.Version, k8sVersion)
|
||||||
schema, ok := c.Get(cacheKey)
|
schema, ok := c.Get(cacheKey)
|
||||||
if !ok {
|
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})
|
validationResults = append(validationResults, validationResult{kind: sig.Kind, version: sig.Version, err: err, skipped: false})
|
||||||
continue
|
continue
|
||||||
}
|
} 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})
|
||||||
if schema == nil {
|
|
||||||
validationResults = append(validationResults, validationResult{kind: sig.Kind, version: sig.Version, err: nil, skipped: true}) // skip if no schema found
|
|
||||||
c.Set(cacheKey, nil)
|
c.Set(cacheKey, nil)
|
||||||
continue
|
continue
|
||||||
|
} else {
|
||||||
|
c.Set(cacheKey, schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Set(cacheKey, schema)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = validator.Validate(rawResource, schema); err != nil {
|
if err = validator.Validate(rawResource, schema); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue