tap plan can be at the end, that way we can stream the output and not buffer

This commit is contained in:
Yann Hamon 2020-12-15 21:54:44 +01:00
parent 706488cafb
commit 07dec90112
4 changed files with 107 additions and 37 deletions

View file

@ -114,11 +114,19 @@ func (val *v) ValidateResource(res resource.Resource) Result {
return Result{Resource: res, Status: Error, Err: fmt.Errorf("error unmarshalling resource: %s", err)}
}
if r == nil { // Resource is empty
return Result{Resource: res, Err: nil, Status: Empty}
}
sig, err := res.SignatureFromMap(r)
if err != nil {
return Result{Resource: res, Err: fmt.Errorf("error while parsing: %s", err), Status: Error}
}
if sig.Kind == "" { // Resource contains key/values but no Kind
return Result{Resource: res, Err: fmt.Errorf("resource missing a Kind"), Status: Error}
}
if skip(*sig) {
return Result{Resource: res, Err: nil, Status: Skipped}
}
@ -127,14 +135,6 @@ func (val *v) ValidateResource(res resource.Resource) Result {
return Result{Resource: res, Err: fmt.Errorf("prohibited resource kind %s", sig.Kind), Status: Error}
}
if r == nil { // Resource is empty
return Result{Resource: res, Err: nil, Status: Empty}
}
if sig.Kind == "" && r != nil { // Resource contains key/values but no Kind
return Result{Resource: res, Err: fmt.Errorf("resource missing a Kind"), Status: Error}
}
cached := false
var schema *gojsonschema.Schema
cacheKey := ""