count empty files in the number of parsed files in text output

This commit is contained in:
Yann Hamon 2020-10-18 13:52:40 +02:00
parent 54d899f8f6
commit 51732e6a21
5 changed files with 24 additions and 5 deletions

View file

@ -65,7 +65,12 @@ func ValidateStream(r io.Reader, regs []registry.Registry, k8sVersion string, c
return []validationResult{{err: fmt.Errorf("failed reading file: %s", err)}}
}
validationResults := []validationResult{}
if len(rawResources) == 0 {
// In case a file has no resources, we want to capture that the file was parsed - and therefore send a message with an empty resource and no error
validationResults = append(validationResults, validationResult{kind: "", version: "", Name: "", err: nil, skipped: false})
}
for _, rawResource := range rawResources {
var sig resource.Signature
@ -75,6 +80,7 @@ func ValidateStream(r io.Reader, regs []registry.Registry, k8sVersion string, c
}
if sig.Kind == "" {
validationResults = append(validationResults, validationResult{kind: "", version: "", Name: "", err: nil, skipped: false})
continue // We skip resoures that don't have a Kind defined
}