Skip to content

Commit

Permalink
Introduce fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhao3300 committed Feb 6, 2020
1 parent 314b8b2 commit ef1599d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kubeval/kubeval.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func validateResource(data []byte, schemaCache map[string]*gojsonschema.Schema,
func validateAgainstSchema(body interface{}, resource *ValidationResult, schemaCache map[string]*gojsonschema.Schema, config *Config) ([]gojsonschema.ResultError, error) {

schema, err := downloadSchema(resource, schemaCache, config)
if err != nil {
if err != nil || schema == nil {
return handleMissingSchema(err, config)
}

Expand All @@ -161,6 +161,7 @@ func validateAgainstSchema(body interface{}, resource *ValidationResult, schemaC
return []gojsonschema.ResultError{}, nil
}

// returned schema may be nil scehma is missing and missing schemas are allowed
func downloadSchema(resource *ValidationResult, schemaCache map[string]*gojsonschema.Schema, config *Config) (*gojsonschema.Schema, error) {
if schema, ok := schemaCache[resource.VersionKind()]; ok {
// If the schema was previously cached, there's no work to be done
Expand Down

0 comments on commit ef1599d

Please sign in to comment.