mirror of https://github.com/k3s-io/k3s
remove TPR registration, ease validation requirements
parent
28d273c8b2
commit
66e5c38d67
|
@ -386,18 +386,6 @@ func (f *factory) UnstructuredObject() (meta.RESTMapper, runtime.ObjectTyper, er
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Register unknown APIs as third party for now to make
|
||||
// validation happy. TODO perhaps make a dynamic schema
|
||||
// validator to avoid this.
|
||||
for _, group := range groupResources {
|
||||
for _, version := range group.Group.Versions {
|
||||
gv := unversioned.GroupVersion{Group: group.Group.Name, Version: version.Version}
|
||||
if !registered.IsRegisteredVersion(gv) {
|
||||
registered.AddThirdPartyAPIGroupVersions(gv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mapper := discovery.NewDeferredDiscoveryRESTMapper(discoveryClient, meta.InterfacesForUnstructured)
|
||||
typer := discovery.NewUnstructuredObjectTyper(groupResources)
|
||||
return NewShortcutExpander(mapper, discoveryClient), typer, nil
|
||||
|
@ -1148,10 +1136,7 @@ func (c *clientSwaggerSchema) ValidateBytes(data []byte) error {
|
|||
return err
|
||||
}
|
||||
if ok := registered.IsEnabledVersion(gvk.GroupVersion()); !ok {
|
||||
return fmt.Errorf("API version %q isn't supported, only supports API versions %q", gvk.GroupVersion().String(), registered.EnabledVersions())
|
||||
}
|
||||
if registered.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
|
||||
// Don't attempt to validate third party objects
|
||||
// if we don't have this in our scheme, just skip validation because its an object we don't recognize
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -30,17 +30,18 @@ import (
|
|||
func TestKubectlValidation(t *testing.T) {
|
||||
testCases := []struct {
|
||||
data string
|
||||
err bool
|
||||
// Validation should not fail on missing type information.
|
||||
err bool
|
||||
}{
|
||||
{`{"apiVersion": "v1", "kind": "thisObjectShouldNotExistInAnyGroup"}`, true},
|
||||
{`{"apiVersion": "invalidVersion", "kind": "Pod"}`, true},
|
||||
{`{"apiVersion": "invalidVersion", "kind": "Pod"}`, false},
|
||||
{`{"apiVersion": "v1", "kind": "Pod"}`, false},
|
||||
|
||||
// The following test the experimental api.
|
||||
// TODO: Replace with something more robust. These may move.
|
||||
{`{"apiVersion": "extensions/v1beta1", "kind": "Ingress"}`, false},
|
||||
{`{"apiVersion": "extensions/v1beta1", "kind": "Job"}`, false},
|
||||
{`{"apiVersion": "vNotAVersion", "kind": "Job"}`, true},
|
||||
{`{"apiVersion": "vNotAVersion", "kind": "Job"}`, false},
|
||||
}
|
||||
components := framework.NewMasterComponents(&framework.Config{})
|
||||
defer components.Stop(true, true)
|
||||
|
|
Loading…
Reference in New Issue