diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index 7806940..df1593d 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -303,10 +303,9 @@ func downloadSchema(registries []registry.Registry, l jsonschema.SchemeURLLoader if err != nil { continue } - return schema, err + return schema, nil } - // If we get a 404, we try the next registry, but we exit if we get a real failure if _, notfound := err.(*loader.NotFoundError); notfound { continue } diff --git a/pkg/validator/validator_test.go b/pkg/validator/validator_test.go index 4e29530..8204862 100644 --- a/pkg/validator/validator_test.go +++ b/pkg/validator/validator_test.go @@ -3,6 +3,7 @@ package validator import ( "bytes" "github.com/santhosh-tekuri/jsonschema/v6" + "github.com/yannh/kubeconform/pkg/loader" "io" "reflect" "testing" @@ -315,7 +316,7 @@ lastName: bar }`), false, false, - Valid, + Error, []ValidationError{}, }, { @@ -360,7 +361,7 @@ lastName: bar []byte(`error page`), true, false, - Skipped, + Error, []ValidationError{}, }, { @@ -389,11 +390,17 @@ lastName: bar schemaDownload: downloadSchema, regs: []registry.Registry{ newMockRegistry(func() (string, any, error) { + if testCase.schemaRegistry1 == nil { + return "", nil, loader.NewNotFoundError(nil) + } s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1)) return "", s, err }), newMockRegistry(func() (string, any, error) { - s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1)) + if testCase.schemaRegistry2 == nil { + return "", nil, loader.NewNotFoundError(nil) + } + s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry2)) return "", s, err }), },