mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-13 08:04:18 +00:00
cache Schema unmarshalling, cache schema download failures (WIP)
This commit is contained in:
parent
87f1a0531e
commit
30a6fe69b1
4 changed files with 22 additions and 25 deletions
|
|
@ -26,15 +26,13 @@ func (f ValidFormat) IsFormat(input interface{}) bool {
|
|||
// gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
|
||||
// }
|
||||
|
||||
func Validate(rawResource []byte, rawSchema []byte) error {
|
||||
schemaLoader := gojsonschema.NewBytesLoader(rawSchema)
|
||||
schema, err := gojsonschema.NewSchema(schemaLoader)
|
||||
if err != nil {
|
||||
return err
|
||||
func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
|
||||
if schema == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var resource map[string]interface{}
|
||||
if err = yaml.Unmarshal(rawResource, &resource); err != nil {
|
||||
if err := yaml.Unmarshal(rawResource, &resource); err != nil {
|
||||
return fmt.Errorf("error unmarshalling resource: %s", err)
|
||||
}
|
||||
resourceLoader := gojsonschema.NewGoLoader(resource)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue