openapi: Validate unregistered type, if they can be found
This commit is contained in:
@@ -18,14 +18,12 @@ package validation
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
apiutil "k8s.io/kubernetes/pkg/api/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
||||
)
|
||||
@@ -76,15 +74,10 @@ func (v *SchemaValidation) validateList(object interface{}) []error {
|
||||
}
|
||||
|
||||
func (v *SchemaValidation) validateResource(obj interface{}, gvk schema.GroupVersionKind) []error {
|
||||
if !api.Registry.IsEnabledVersion(gvk.GroupVersion()) {
|
||||
// if we don't have this in our scheme, just skip
|
||||
// validation because its an object we don't recognize
|
||||
return nil
|
||||
}
|
||||
|
||||
resource := v.resources.LookupResource(gvk)
|
||||
if resource == nil {
|
||||
return []error{fmt.Errorf("unknown object type %#v", gvk)}
|
||||
// resource is not present, let's just skip validation.
|
||||
return nil
|
||||
}
|
||||
|
||||
rootValidation, err := itemFactory(openapi.NewPath(gvk.Kind), obj)
|
||||
|
Reference in New Issue
Block a user