apimachinery: remove pre-apigroups import prefix logic

This commit is contained in:
Dr. Stefan Schimanski 2017-08-03 17:49:35 +02:00
parent 291eaeec29
commit 8728576236
37 changed files with 4 additions and 49 deletions

View File

@ -35,7 +35,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: kubeadm.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm",
AddInternalObjectsToScheme: kubeadm.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -35,7 +35,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: core.GroupName,
VersionPreferenceOrder: []string{corev1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/federation/apis/core",
AddInternalObjectsToScheme: core.AddToScheme,
RootScopedKinds: sets.NewString(
"Namespace",

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: federation.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/federation/apis/federation",
AddInternalObjectsToScheme: federation.AddToScheme,
RootScopedKinds: sets.NewString(
"Cluster",

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: api.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/core",
AddInternalObjectsToScheme: api.AddToScheme,
RootScopedKinds: sets.NewString(
"Node",

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: admission.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/admission",
RootScopedKinds: sets.NewString("AdmissionReview"),
AddInternalObjectsToScheme: admission.AddToScheme,
},

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
GroupName: admissionregistration.GroupName,
RootScopedKinds: sets.NewString("InitializerConfiguration", "ExternalAdmissionHookConfiguration"),
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/admissionregistration",
AddInternalObjectsToScheme: admissionregistration.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: apps.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version, v1beta2.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/apps",
AddInternalObjectsToScheme: apps.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -39,7 +39,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: authentication.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/authentication",
RootScopedKinds: sets.NewString("TokenReview"),
AddInternalObjectsToScheme: authentication.AddToScheme,
},

View File

@ -39,7 +39,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: authorization.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/authorization",
RootScopedKinds: sets.NewString("SubjectAccessReview", "SelfSubjectAccessReview"),
AddInternalObjectsToScheme: authorization.AddToScheme,
},

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: autoscaling.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v2alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/autoscaling",
AddInternalObjectsToScheme: autoscaling.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: batch.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v2alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/batch",
AddInternalObjectsToScheme: batch.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: certificates.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/certificates",
RootScopedKinds: sets.NewString("CertificateSigningRequest"),
AddInternalObjectsToScheme: certificates.AddToScheme,
},

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: componentconfig.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/pkg/apis/componentconfig",
AddInternalObjectsToScheme: componentconfig.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: extensions.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/extensions",
RootScopedKinds: sets.NewString("PodSecurityPolicy", "ThirdPartyResource"),
AddInternalObjectsToScheme: extensions.AddToScheme,
},

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: imagepolicy.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/imagepolicy",
RootScopedKinds: sets.NewString("ImageReview"),
AddInternalObjectsToScheme: imagepolicy.AddToScheme,
},

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: networking.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/networking",
AddInternalObjectsToScheme: networking.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: policy.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/policy",
AddInternalObjectsToScheme: policy.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -50,7 +50,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
// 1.10 (once all stored objects are at v1):
// * remove v1alpha1
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version, v1.SchemeGroupVersion.Version, v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/rbac",
RootScopedKinds: sets.NewString("ClusterRole", "ClusterRoleBinding"),
AddInternalObjectsToScheme: rbac.AddToScheme,
},

View File

@ -38,7 +38,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: scheduling.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/scheduling",
RootScopedKinds: sets.NewString("PriorityClass"),
AddInternalObjectsToScheme: scheduling.AddToScheme,
},

View File

@ -37,7 +37,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: settings.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/settings",
AddInternalObjectsToScheme: settings.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -39,7 +39,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: storage.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/api/storage",
RootScopedKinds: sets.NewString("StorageClass"),
AddInternalObjectsToScheme: storage.AddToScheme,
},

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: internalapi.GroupName,
VersionPreferenceOrder: []string{versionedapi.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction",
AddInternalObjectsToScheme: internalapi.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: resourcequotaapi.GroupName,
VersionPreferenceOrder: []string{resourcequotav1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/plugin/pkg/admission/resourcequota/apis/resourcequota",
AddInternalObjectsToScheme: resourcequotaapi.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
GroupName: apiextensions.GroupName,
RootScopedKinds: sets.NewString("CustomResourceDefinition"),
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/apiextensions-apiserver/pkg/apis/apiextension",
AddInternalObjectsToScheme: apiextensions.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -17,8 +17,6 @@ limitations under the License.
package meta
import (
"strings"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
@ -26,18 +24,15 @@ import (
// NewDefaultRESTMapperFromScheme instantiates a DefaultRESTMapper based on types registered in the given scheme.
func NewDefaultRESTMapperFromScheme(defaultGroupVersions []schema.GroupVersion, interfacesFunc VersionInterfacesFunc,
importPathPrefix string, ignoredKinds, rootScoped sets.String, scheme *runtime.Scheme) *DefaultRESTMapper {
ignoredKinds, rootScoped sets.String, scheme *runtime.Scheme) *DefaultRESTMapper {
mapper := NewDefaultRESTMapper(defaultGroupVersions, interfacesFunc)
// enumerate all supported versions, get the kinds, and register with the mapper how to address
// our resources.
for _, gv := range defaultGroupVersions {
for kind, oType := range scheme.KnownTypes(gv) {
for kind := range scheme.KnownTypes(gv) {
gvk := gv.WithKind(kind)
// TODO: Remove import path check.
// We check the import path because we currently stuff both "api" and "extensions" objects
// into the same group within Scheme since Scheme has no notion of groups yet.
if !strings.Contains(oType.PkgPath(), importPathPrefix) || ignoredKinds.Has(kind) {
if ignoredKinds.Has(kind) {
continue
}
scope := RESTScopeNamespace

View File

@ -30,7 +30,6 @@ func TestFactoryRegistry(t *testing.T) {
if err := regA.AnnounceGroup(&GroupMetaFactoryArgs{
GroupName: "foo",
VersionPreferenceOrder: []string{"v2", "v1"},
ImportPrefix: "pkg/apis/foo",
RootScopedKinds: sets.NewString("namespaces"),
}); err != nil {
t.Fatalf("Unexpected error: %v", err)
@ -52,7 +51,6 @@ func TestFactoryRegistry(t *testing.T) {
&GroupMetaFactoryArgs{
GroupName: "foo",
VersionPreferenceOrder: []string{"v2", "v1"},
ImportPrefix: "pkg/apis/foo",
RootScopedKinds: sets.NewString("namespaces"),
},
VersionToSchemeFunc{"v1": nil, "v2": nil},

View File

@ -47,10 +47,6 @@ type GroupMetaFactoryArgs struct {
// example: 'servicecatalog.k8s.io'
GroupName string
VersionPreferenceOrder []string
// ImportPrefix is the base go package of the API-Group
//
// example: 'k8s.io/kubernetes/pkg/apis/autoscaling'
ImportPrefix string
// RootScopedKinds are resources that are not namespaced.
RootScopedKinds sets.String // nil is allowed
IgnoredKinds sets.String // nil is allowed
@ -179,7 +175,6 @@ func (gmf *GroupMetaFactory) newRESTMapper(scheme *runtime.Scheme, externalVersi
return meta.NewDefaultRESTMapperFromScheme(
externalVersions,
groupMeta.InterfacesFor,
gmf.GroupArgs.ImportPrefix,
ignoredKinds,
rootScoped,
scheme,

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: testapigroup.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/apimachinery/pkg/apis/testapigroup",
AddInternalObjectsToScheme: testapigroup.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
GroupName: apiserver.GroupName,
RootScopedKinds: sets.NewString("APIService"),
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/apiserver/pkg/apis/apiserver",
AddInternalObjectsToScheme: apiserver.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -33,7 +33,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: audit.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/apiserver/pkg/apis/audit",
// Any Kind that is not namespaced must be cluster scoped.
RootScopedKinds: sets.NewString("Event", "Policy"),
AddInternalObjectsToScheme: audit.AddToScheme,

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: example.GroupName,
VersionPreferenceOrder: []string{examplev1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/apiserver/pkg/apis/example",
AddInternalObjectsToScheme: example.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -167,7 +167,7 @@ func TestInstallAPIGroups(t *testing.T) {
}, nil
}
mapper := meta.NewDefaultRESTMapperFromScheme([]schema.GroupVersion{gv}, interfacesFor, "", sets.NewString(), sets.NewString(), scheme)
mapper := meta.NewDefaultRESTMapperFromScheme([]schema.GroupVersion{gv}, interfacesFor, sets.NewString(), sets.NewString(), scheme)
groupMeta := apimachinery.GroupMeta{
GroupVersion: gv,
GroupVersions: []schema.GroupVersion{gv},

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
GroupName: apiregistration.GroupName,
RootScopedKinds: sets.NewString("APIService"),
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kube-aggregator/pkg/apis/apiregistration",
AddInternalObjectsToScheme: apiregistration.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: testgroup.SchemeGroupVersion.Group,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kube-gen/test/apis/testgroup",
AddInternalObjectsToScheme: testgroup.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: custom_metrics.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/metrics/pkg/apis/custom_metrics",
AddInternalObjectsToScheme: custom_metrics.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -33,7 +33,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: metrics.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/metrics/pkg/apis/metrics",
RootScopedKinds: sets.NewString("NodeMetrics"),
AddInternalObjectsToScheme: metrics.AddToScheme,
},

View File

@ -32,7 +32,6 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
GroupName: wardle.GroupName,
RootScopedKinds: sets.NewString("Fischer", "FischerList"),
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/sample-apiserver/pkg/apis/wardle",
AddInternalObjectsToScheme: wardle.AddToScheme,
},
announced.VersionToSchemeFunc{