From e7fbbe0e3c91f34836b999e695aa133503cfdae5 Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 24 Apr 2018 08:21:23 -0400 Subject: [PATCH] eliminate indirection from type registration --- cmd/kube-apiserver/app/testing/testserver.go | 1 + .../app/apis/kubeadm/install/install.go | 6 +- pkg/api/legacyscheme/scheme.go | 4 - pkg/api/testing/meta_test.go | 2 +- pkg/apis/admission/install/install.go | 6 +- .../admissionregistration/install/install.go | 6 +- pkg/apis/apps/install/install.go | 6 +- pkg/apis/authentication/install/install.go | 6 +- pkg/apis/authorization/install/install.go | 6 +- pkg/apis/autoscaling/install/install.go | 6 +- pkg/apis/batch/install/install.go | 6 +- pkg/apis/certificates/install/install.go | 6 +- pkg/apis/componentconfig/install/install.go | 6 +- pkg/apis/core/install/install.go | 6 +- pkg/apis/events/install/install.go | 6 +- pkg/apis/extensions/install/install.go | 6 +- pkg/apis/imagepolicy/install/install.go | 6 +- pkg/apis/networking/install/install.go | 6 +- pkg/apis/policy/install/install.go | 6 +- pkg/apis/rbac/install/install.go | 6 +- pkg/apis/scheduling/install/install.go | 6 +- pkg/apis/settings/install/install.go | 6 +- pkg/apis/storage/install/install.go | 6 +- .../scheme/register_custom.go | 5 +- pkg/kubectl/cmd/convert.go | 2 +- pkg/kubectl/cmd/util/factory_client_access.go | 2 +- pkg/kubectl/cmd/util/printing.go | 2 +- pkg/kubectl/scheme/install.go | 34 +++--- pkg/kubectl/scheme/scheme.go | 4 - pkg/kubelet/config/common_test.go | 4 +- pkg/kubelet/kubeletconfig/status/status.go | 2 +- pkg/kubelet/kubeletconfig/util/codec/codec.go | 2 +- pkg/master/master.go | 41 ++++--- pkg/printers/humanreadable_flags.go | 2 +- pkg/printers/internalversion/printers_test.go | 10 +- pkg/registry/core/rest/storage_core.go | 6 +- .../apis/eventratelimit/install/install.go | 4 +- plugin/pkg/admission/eventratelimit/config.go | 10 +- .../install/install.go | 4 +- .../podtolerationrestriction/config.go | 10 +- .../apis/resourcequota/install/install.go | 4 +- plugin/pkg/admission/resourcequota/config.go | 10 +- .../pkg/apis/apiextensions/install/install.go | 4 +- .../pkg/apiserver/apiserver.go | 10 +- .../pkg/api/testing/roundtrip/roundtrip.go | 9 +- .../pkg/apimachinery/announced/announced.go | 99 ---------------- .../apimachinery/announced/announced_test.go | 64 ----------- .../apimachinery/announced/group_factory.go | 108 ++++++------------ .../pkg/apimachinery/registered/registered.go | 98 +++++----------- .../pkg/apis/testapigroup/install/install.go | 4 +- .../apis/webhookadmission/install/install.go | 4 +- .../pkg/apis/apiserver/install/install.go | 4 +- .../pkg/apis/audit/install/install.go | 4 +- .../pkg/apis/example/install/install.go | 4 +- .../pkg/apis/example2/install/install.go | 4 +- .../pkg/endpoints/discovery/root_test.go | 8 +- .../pkg/server/resourceconfig/helpers_test.go | 7 +- .../server/storage/storage_factory_test.go | 7 +- .../apiserver/pkg/util/webhook/webhook.go | 2 +- .../plugin/pkg/audit/log/backend_test.go | 10 +- .../plugin/pkg/audit/webhook/webhook.go | 8 +- .../authenticator/token/webhook/webhook.go | 4 - .../plugin/pkg/authorizer/webhook/webhook.go | 3 - .../clientauthentication/install/install.go | 4 +- .../apiserver/apis/example/install/install.go | 4 +- .../apis/example2/install/install.go | 4 +- .../apis/apiregistration/install/install.go | 4 +- .../pkg/apiserver/scheme/scheme.go | 5 +- .../apis/custom_metrics/install/install.go | 4 +- .../apis/external_metrics/install/install.go | 4 +- .../pkg/apis/metrics/install/install.go | 4 +- .../pkg/apis/wardle/install/install.go | 4 +- .../pkg/apiserver/apiserver.go | 10 +- test/e2e/apps/daemon_set.go | 4 +- 74 files changed, 265 insertions(+), 536 deletions(-) delete mode 100644 staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced.go delete mode 100644 staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced_test.go diff --git a/cmd/kube-apiserver/app/testing/testserver.go b/cmd/kube-apiserver/app/testing/testserver.go index 3b16c510d5..435382821e 100644 --- a/cmd/kube-apiserver/app/testing/testserver.go +++ b/cmd/kube-apiserver/app/testing/testserver.go @@ -107,6 +107,7 @@ func StartTestServer(t Logger, customFlags []string, storageConfig *storagebacke return result, fmt.Errorf("failed to set default ServerRunOptions: %v", err) } + t.Logf("runtime-config=%v", completedOptions.APIEnablement.RuntimeConfig) t.Logf("Starting kube-apiserver on port %d...", s.SecureServing.BindPort) server, err := app.CreateServerChain(completedOptions, stopCh) if err != nil { diff --git a/cmd/kubeadm/app/apis/kubeadm/install/install.go b/cmd/kubeadm/app/apis/kubeadm/install/install.go index 0e1ebfca4d..5d50b746ff 100644 --- a/cmd/kubeadm/app/apis/kubeadm/install/install.go +++ b/cmd/kubeadm/app/apis/kubeadm/install/install.go @@ -26,11 +26,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: kubeadm.GroupName, @@ -40,7 +40,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/api/legacyscheme/scheme.go b/pkg/api/legacyscheme/scheme.go index 64c63a3606..37059fdd7d 100644 --- a/pkg/api/legacyscheme/scheme.go +++ b/pkg/api/legacyscheme/scheme.go @@ -19,15 +19,11 @@ package legacyscheme import ( "os" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" ) -// GroupFactoryRegistry is the APIGroupFactoryRegistry (overlaps a bit with Registry, see comments in package for details) -var GroupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - // Registry is an instance of an API registry. This is an interim step to start removing the idea of a global // API registry. var Registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) diff --git a/pkg/api/testing/meta_test.go b/pkg/api/testing/meta_test.go index d7a62798cb..d7f23567c7 100644 --- a/pkg/api/testing/meta_test.go +++ b/pkg/api/testing/meta_test.go @@ -30,7 +30,7 @@ import ( var _ metav1.Object = &metav1.ObjectMeta{} func TestAccessorImplementations(t *testing.T) { - for _, gv := range legacyscheme.Registry.EnabledVersions() { + for _, gv := range legacyscheme.Registry.RegisteredGroupVersions() { internalGV := schema.GroupVersion{Group: gv.Group, Version: runtime.APIVersionInternal} for _, gv := range []schema.GroupVersion{gv, internalGV} { for kind, knownType := range legacyscheme.Scheme.KnownTypes(gv) { diff --git a/pkg/apis/admission/install/install.go b/pkg/apis/admission/install/install.go index 404f549c38..4c10ce819c 100644 --- a/pkg/apis/admission/install/install.go +++ b/pkg/apis/admission/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: admission.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/admissionregistration/install/install.go b/pkg/apis/admissionregistration/install/install.go index 81f4ff2ffc..36a1efac39 100644 --- a/pkg/apis/admissionregistration/install/install.go +++ b/pkg/apis/admissionregistration/install/install.go @@ -28,11 +28,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: admissionregistration.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/apps/install/install.go b/pkg/apis/apps/install/install.go index 4f9dcfe9a1..ac71542f42 100644 --- a/pkg/apis/apps/install/install.go +++ b/pkg/apis/apps/install/install.go @@ -30,11 +30,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: apps.GroupName, @@ -46,7 +46,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta2.SchemeGroupVersion.Version: v1beta2.AddToScheme, v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/authentication/install/install.go b/pkg/apis/authentication/install/install.go index 3e1271dcbc..b154d19e04 100644 --- a/pkg/apis/authentication/install/install.go +++ b/pkg/apis/authentication/install/install.go @@ -30,11 +30,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: authentication.GroupName, @@ -46,7 +46,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/authorization/install/install.go b/pkg/apis/authorization/install/install.go index 2a9cbf6bd2..5e0dfaec4a 100644 --- a/pkg/apis/authorization/install/install.go +++ b/pkg/apis/authorization/install/install.go @@ -30,11 +30,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: authorization.GroupName, @@ -46,7 +46,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/autoscaling/install/install.go b/pkg/apis/autoscaling/install/install.go index 507f2b17f5..63853b8dc3 100644 --- a/pkg/apis/autoscaling/install/install.go +++ b/pkg/apis/autoscaling/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: autoscaling.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1.SchemeGroupVersion.Version: v1.AddToScheme, v2beta1.SchemeGroupVersion.Version: v2beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/batch/install/install.go b/pkg/apis/batch/install/install.go index e04f926057..043f559e48 100644 --- a/pkg/apis/batch/install/install.go +++ b/pkg/apis/batch/install/install.go @@ -30,11 +30,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: batch.GroupName, @@ -46,7 +46,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, v2alpha1.SchemeGroupVersion.Version: v2alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/certificates/install/install.go b/pkg/apis/certificates/install/install.go index a4e9bb39db..b26205cebb 100644 --- a/pkg/apis/certificates/install/install.go +++ b/pkg/apis/certificates/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: certificates.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/componentconfig/install/install.go b/pkg/apis/componentconfig/install/install.go index d5e48363b4..3911b06b15 100644 --- a/pkg/apis/componentconfig/install/install.go +++ b/pkg/apis/componentconfig/install/install.go @@ -28,11 +28,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: componentconfig.GroupName, @@ -42,7 +42,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/core/install/install.go b/pkg/apis/core/install/install.go index cae514ec7b..99a251fb66 100644 --- a/pkg/apis/core/install/install.go +++ b/pkg/apis/core/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: core.GroupName, @@ -61,7 +61,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/events/install/install.go b/pkg/apis/events/install/install.go index 9dbc1b4d47..cb2cc66b23 100644 --- a/pkg/apis/events/install/install.go +++ b/pkg/apis/events/install/install.go @@ -28,11 +28,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: events.GroupName, @@ -42,7 +42,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/extensions/install/install.go b/pkg/apis/extensions/install/install.go index dfa8991012..54d4d3653b 100644 --- a/pkg/apis/extensions/install/install.go +++ b/pkg/apis/extensions/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: extensions.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/imagepolicy/install/install.go b/pkg/apis/imagepolicy/install/install.go index 75f5ba1f44..686925dfbc 100644 --- a/pkg/apis/imagepolicy/install/install.go +++ b/pkg/apis/imagepolicy/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: imagepolicy.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/networking/install/install.go b/pkg/apis/networking/install/install.go index 59a3d043c5..1047c4379a 100644 --- a/pkg/apis/networking/install/install.go +++ b/pkg/apis/networking/install/install.go @@ -28,11 +28,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: networking.GroupName, @@ -42,7 +42,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/policy/install/install.go b/pkg/apis/policy/install/install.go index 7a6db95728..1d01c8c844 100644 --- a/pkg/apis/policy/install/install.go +++ b/pkg/apis/policy/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: policy.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/rbac/install/install.go b/pkg/apis/rbac/install/install.go index b03d8475cd..1af62ef247 100644 --- a/pkg/apis/rbac/install/install.go +++ b/pkg/apis/rbac/install/install.go @@ -31,11 +31,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: rbac.GroupName, @@ -51,7 +51,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/scheduling/install/install.go b/pkg/apis/scheduling/install/install.go index 0a47a8815c..049fab3c7f 100644 --- a/pkg/apis/scheduling/install/install.go +++ b/pkg/apis/scheduling/install/install.go @@ -29,11 +29,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: scheduling.GroupName, @@ -44,7 +44,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/settings/install/install.go b/pkg/apis/settings/install/install.go index bf4ae5c579..75f68644e1 100644 --- a/pkg/apis/settings/install/install.go +++ b/pkg/apis/settings/install/install.go @@ -28,11 +28,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: settings.GroupName, @@ -42,7 +42,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/apis/storage/install/install.go b/pkg/apis/storage/install/install.go index 28fa786596..c2fe34ddd2 100644 --- a/pkg/apis/storage/install/install.go +++ b/pkg/apis/storage/install/install.go @@ -31,11 +31,11 @@ import ( ) func init() { - Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) + Install(legacyscheme.Registry, legacyscheme.Scheme) } // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: storage.GroupName, @@ -51,7 +51,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/pkg/client/clientset_generated/internalclientset/scheme/register_custom.go b/pkg/client/clientset_generated/internalclientset/scheme/register_custom.go index d54eb1ccef..4649558a12 100644 --- a/pkg/client/clientset_generated/internalclientset/scheme/register_custom.go +++ b/pkg/client/clientset_generated/internalclientset/scheme/register_custom.go @@ -17,13 +17,12 @@ limitations under the License. package scheme import ( - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime" componentconfig "k8s.io/kubernetes/pkg/apis/componentconfig/install" ) -func ExtraInstall(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func ExtraInstall(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { // componentconfig is an apigroup, but we don't have an API endpoint because its objects are just embedded in ConfigMaps. - componentconfig.Install(groupFactoryRegistry, registry, scheme) + componentconfig.Install(registry, scheme) } diff --git a/pkg/kubectl/cmd/convert.go b/pkg/kubectl/cmd/convert.go index 634a991678..715c915370 100644 --- a/pkg/kubectl/cmd/convert.go +++ b/pkg/kubectl/cmd/convert.go @@ -279,7 +279,7 @@ func asVersionedObjects(infos []*resource.Info, specifiedOutputVersion schema.Gr gvks, _, err := scheme.Scheme.ObjectKinds(info.Object) if err == nil { for _, gvk := range gvks { - for _, version := range scheme.Registry.EnabledVersionsForGroup(gvk.Group) { + for _, version := range scheme.Registry.RegisteredVersionsForGroup(gvk.Group) { targetVersions = append(targetVersions, version) } } diff --git a/pkg/kubectl/cmd/util/factory_client_access.go b/pkg/kubectl/cmd/util/factory_client_access.go index 34e27f8c78..bcc018f360 100644 --- a/pkg/kubectl/cmd/util/factory_client_access.go +++ b/pkg/kubectl/cmd/util/factory_client_access.go @@ -719,7 +719,7 @@ func InternalVersionDecoder() runtime.Decoder { } func InternalVersionJSONEncoder() runtime.Encoder { - encoder := legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...) + encoder := legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...) return unstructured.JSONFallbackEncoder{Encoder: encoder} } diff --git a/pkg/kubectl/cmd/util/printing.go b/pkg/kubectl/cmd/util/printing.go index fa33f25a36..5612711939 100644 --- a/pkg/kubectl/cmd/util/printing.go +++ b/pkg/kubectl/cmd/util/printing.go @@ -136,7 +136,7 @@ func PrintObject(cmd *cobra.Command, obj runtime.Object, out io.Writer) error { func PrinterForOptions(options *printers.PrintOptions) (printers.ResourcePrinter, error) { // TODO: used by the custom column implementation and the name implementation, break this dependency decoders := []runtime.Decoder{kubectlscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme} - encoder := kubectlscheme.Codecs.LegacyCodec(kubectlscheme.Registry.EnabledVersions()...) + encoder := kubectlscheme.Codecs.LegacyCodec(kubectlscheme.Registry.RegisteredGroupVersions()...) printer, err := printers.GetStandardPrinter(kubectlscheme.Scheme, encoder, decoders, *options) if err != nil { diff --git a/pkg/kubectl/scheme/install.go b/pkg/kubectl/scheme/install.go index 95838f5570..87caea0645 100644 --- a/pkg/kubectl/scheme/install.go +++ b/pkg/kubectl/scheme/install.go @@ -87,7 +87,7 @@ func init() { announced.VersionToSchemeFunc{ corev1.SchemeGroupVersion.Version: corev1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -101,7 +101,7 @@ func init() { announced.VersionToSchemeFunc{ admissionv1alpha1.SchemeGroupVersion.Version: admissionv1alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -115,7 +115,7 @@ func init() { announced.VersionToSchemeFunc{ admissionregistrationv1alpha1.SchemeGroupVersion.Version: admissionregistrationv1alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -130,7 +130,7 @@ func init() { appsv1beta2.SchemeGroupVersion.Version: appsv1beta2.AddToScheme, appsv1.SchemeGroupVersion.Version: appsv1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -145,7 +145,7 @@ func init() { authenticationv1beta1.SchemeGroupVersion.Version: authenticationv1beta1.AddToScheme, authenticationv1.SchemeGroupVersion.Version: authenticationv1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -160,7 +160,7 @@ func init() { authorizationv1beta1.SchemeGroupVersion.Version: authorizationv1beta1.AddToScheme, authorizationv1.SchemeGroupVersion.Version: authorizationv1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -174,7 +174,7 @@ func init() { autoscalingv1.SchemeGroupVersion.Version: autoscalingv1.AddToScheme, autoscalingv2beta1.SchemeGroupVersion.Version: autoscalingv2beta1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -189,7 +189,7 @@ func init() { batchv1beta1.SchemeGroupVersion.Version: batchv1beta1.AddToScheme, batchv2alpha1.SchemeGroupVersion.Version: batchv2alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -203,7 +203,7 @@ func init() { announced.VersionToSchemeFunc{ certificatesv1beta1.SchemeGroupVersion.Version: certificatesv1beta1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -217,7 +217,7 @@ func init() { announced.VersionToSchemeFunc{ extensionsv1beta1.SchemeGroupVersion.Version: extensionsv1beta1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -231,7 +231,7 @@ func init() { announced.VersionToSchemeFunc{ imagepolicyv1alpha1.SchemeGroupVersion.Version: imagepolicyv1alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -244,7 +244,7 @@ func init() { announced.VersionToSchemeFunc{ networkingv1.SchemeGroupVersion.Version: networkingv1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -257,7 +257,7 @@ func init() { announced.VersionToSchemeFunc{ policyv1beta1.SchemeGroupVersion.Version: policyv1beta1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -273,7 +273,7 @@ func init() { rbacv1beta1.SchemeGroupVersion.Version: rbacv1beta1.AddToScheme, rbacv1alpha1.SchemeGroupVersion.Version: rbacv1alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -287,7 +287,7 @@ func init() { announced.VersionToSchemeFunc{ schedulingv1alpha1.SchemeGroupVersion.Version: schedulingv1alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -300,7 +300,7 @@ func init() { announced.VersionToSchemeFunc{ settingsv1alpha1.SchemeGroupVersion.Version: settingsv1alpha1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } @@ -315,7 +315,7 @@ func init() { storagev1.SchemeGroupVersion.Version: storagev1.AddToScheme, storagev1beta1.SchemeGroupVersion.Version: storagev1beta1.AddToScheme, }, - ).Announce(GroupFactoryRegistry).RegisterAndEnable(Registry, Scheme); err != nil { + ).Register(Registry, Scheme); err != nil { panic(err) } } diff --git a/pkg/kubectl/scheme/scheme.go b/pkg/kubectl/scheme/scheme.go index 1140f60904..e4a2fccfb0 100644 --- a/pkg/kubectl/scheme/scheme.go +++ b/pkg/kubectl/scheme/scheme.go @@ -19,7 +19,6 @@ package scheme import ( "os" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -29,9 +28,6 @@ import ( // All kubectl code should eventually switch to use this Registry and Scheme instead of the global ones. -// GroupFactoryRegistry is the APIGroupFactoryRegistry (overlaps a bit with Registry, see comments in package for details) -var GroupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - // Registry is an instance of an API registry. var Registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) diff --git a/pkg/kubelet/config/common_test.go b/pkg/kubelet/config/common_test.go index 4517349186..55cc54c788 100644 --- a/pkg/kubelet/config/common_test.go +++ b/pkg/kubelet/config/common_test.go @@ -78,7 +78,7 @@ func TestDecodeSinglePod(t *testing.T) { t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(json)) } - for _, gv := range legacyscheme.Registry.EnabledVersionsForGroup(v1.GroupName) { + for _, gv := range legacyscheme.Registry.RegisteredVersionsForGroup(v1.GroupName) { info, _ := runtime.SerializerInfoForMediaType(legacyscheme.Codecs.SupportedMediaTypes(), "application/yaml") encoder := legacyscheme.Codecs.EncoderForVersion(info.Serializer, gv) yaml, err := runtime.Encode(encoder, pod) @@ -144,7 +144,7 @@ func TestDecodePodList(t *testing.T) { t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", podList, &podListOut, string(json)) } - for _, gv := range legacyscheme.Registry.EnabledVersionsForGroup(v1.GroupName) { + for _, gv := range legacyscheme.Registry.RegisteredVersionsForGroup(v1.GroupName) { info, _ := runtime.SerializerInfoForMediaType(legacyscheme.Codecs.SupportedMediaTypes(), "application/yaml") encoder := legacyscheme.Codecs.EncoderForVersion(info.Serializer, gv) yaml, err := runtime.Encode(encoder, podList) diff --git a/pkg/kubelet/kubeletconfig/status/status.go b/pkg/kubelet/kubeletconfig/status/status.go index 184d916ca0..014b7981d6 100644 --- a/pkg/kubelet/kubeletconfig/status/status.go +++ b/pkg/kubelet/kubeletconfig/status/status.go @@ -256,7 +256,7 @@ func (c *configOkCondition) Sync(client clientset.Interface, nodeName string) { err = fmt.Errorf("unsupported media type %q", mediaType) return } - versions := legacyscheme.Registry.EnabledVersionsForGroup(api.GroupName) + versions := legacyscheme.Registry.RegisteredVersionsForGroup(api.GroupName) if len(versions) == 0 { err = fmt.Errorf("no enabled versions for group %q", api.GroupName) return diff --git a/pkg/kubelet/kubeletconfig/util/codec/codec.go b/pkg/kubelet/kubeletconfig/util/codec/codec.go index 73bc81a607..c499ac8c0c 100644 --- a/pkg/kubelet/kubeletconfig/util/codec/codec.go +++ b/pkg/kubelet/kubeletconfig/util/codec/codec.go @@ -67,7 +67,7 @@ func NewYAMLEncoder(groupName string) (runtime.Encoder, error) { return nil, fmt.Errorf("unsupported media type %q", mediaType) } - versions := legacyscheme.Registry.EnabledVersionsForGroup(groupName) + versions := legacyscheme.Registry.RegisteredVersionsForGroup(groupName) if len(versions) == 0 { return nil, fmt.Errorf("no enabled versions for group %q", groupName) } diff --git a/pkg/master/master.go b/pkg/master/master.go index d43c522cb3..bd14632021 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -24,6 +24,7 @@ import ( "strconv" "time" + admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" @@ -36,6 +37,7 @@ import ( autoscalingapiv2beta1 "k8s.io/api/autoscaling/v2beta1" batchapiv1 "k8s.io/api/batch/v1" batchapiv1beta1 "k8s.io/api/batch/v1beta1" + batchapiv2alpha1 "k8s.io/api/batch/v2alpha1" certificatesapiv1beta1 "k8s.io/api/certificates/v1beta1" apiv1 "k8s.io/api/core/v1" eventsv1beta1 "k8s.io/api/events/v1beta1" @@ -43,8 +45,12 @@ import ( networkingapiv1 "k8s.io/api/networking/v1" policyapiv1beta1 "k8s.io/api/policy/v1beta1" rbacv1 "k8s.io/api/rbac/v1" + rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" rbacv1beta1 "k8s.io/api/rbac/v1beta1" + schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1" + settingsv1alpha1 "k8s.io/api/settings/v1alpha1" storageapiv1 "k8s.io/api/storage/v1" + storageapiv1alpha1 "k8s.io/api/storage/v1alpha1" storageapiv1beta1 "k8s.io/api/storage/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilnet "k8s.io/apimachinery/pkg/util/net" @@ -456,28 +462,37 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig { ret := serverstorage.NewResourceConfig() // NOTE: GroupVersions listed here will be enabled by default. Don't put alpha versions in the list. ret.EnableVersions( + admissionregistrationv1beta1.SchemeGroupVersion, apiv1.SchemeGroupVersion, - extensionsapiv1beta1.SchemeGroupVersion, - batchapiv1.SchemeGroupVersion, - batchapiv1beta1.SchemeGroupVersion, - authenticationv1.SchemeGroupVersion, - authenticationv1beta1.SchemeGroupVersion, - autoscalingapiv1.SchemeGroupVersion, - autoscalingapiv2beta1.SchemeGroupVersion, appsv1beta1.SchemeGroupVersion, appsv1beta2.SchemeGroupVersion, appsv1.SchemeGroupVersion, + authenticationv1.SchemeGroupVersion, + authenticationv1beta1.SchemeGroupVersion, + authorizationapiv1.SchemeGroupVersion, + authorizationapiv1beta1.SchemeGroupVersion, + autoscalingapiv1.SchemeGroupVersion, + autoscalingapiv2beta1.SchemeGroupVersion, + batchapiv1.SchemeGroupVersion, + batchapiv1beta1.SchemeGroupVersion, + certificatesapiv1beta1.SchemeGroupVersion, + eventsv1beta1.SchemeGroupVersion, + extensionsapiv1beta1.SchemeGroupVersion, + networkingapiv1.SchemeGroupVersion, policyapiv1beta1.SchemeGroupVersion, rbacv1.SchemeGroupVersion, rbacv1beta1.SchemeGroupVersion, storageapiv1.SchemeGroupVersion, storageapiv1beta1.SchemeGroupVersion, - certificatesapiv1beta1.SchemeGroupVersion, - authorizationapiv1.SchemeGroupVersion, - authorizationapiv1beta1.SchemeGroupVersion, - networkingapiv1.SchemeGroupVersion, - eventsv1beta1.SchemeGroupVersion, - admissionregistrationv1beta1.SchemeGroupVersion, + ) + // disable alpha versions explicitly so we have a full list of what's possible to serve + ret.DisableVersions( + admissionregistrationv1alpha1.SchemeGroupVersion, + batchapiv2alpha1.SchemeGroupVersion, + rbacv1alpha1.SchemeGroupVersion, + schedulingv1alpha1.SchemeGroupVersion, + settingsv1alpha1.SchemeGroupVersion, + storageapiv1alpha1.SchemeGroupVersion, ) return ret diff --git a/pkg/printers/humanreadable_flags.go b/pkg/printers/humanreadable_flags.go index 4c6ddadab0..7b657f5008 100644 --- a/pkg/printers/humanreadable_flags.go +++ b/pkg/printers/humanreadable_flags.go @@ -47,7 +47,7 @@ func (f *HumanPrintFlags) ToPrinter(outputFormat string) (ResourcePrinter, bool, return nil, false, nil } - encoder := scheme.Codecs.LegacyCodec(scheme.Registry.EnabledVersions()...) + encoder := scheme.Codecs.LegacyCodec(scheme.Registry.RegisteredGroupVersions()...) decoder := scheme.Codecs.UniversalDecoder() showKind := false diff --git a/pkg/printers/internalversion/printers_test.go b/pkg/printers/internalversion/printers_test.go index 1e5b26f365..fe9afba96c 100644 --- a/pkg/printers/internalversion/printers_test.go +++ b/pkg/printers/internalversion/printers_test.go @@ -109,7 +109,7 @@ func TestPrintDefault(t *testing.T) { } for _, test := range printerTests { - printer, err := printers.GetStandardPrinter(nil, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, printers.PrintOptions{AllowMissingKeys: false}) + printer, err := printers.GetStandardPrinter(nil, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, printers.PrintOptions{AllowMissingKeys: false}) if err != nil { t.Errorf("in %s, unexpected error: %#v", test.Name, err) } @@ -284,7 +284,7 @@ func TestPrinter(t *testing.T) { } for _, test := range printerTests { buf := bytes.NewBuffer([]byte{}) - printer, err := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *test.PrintOpts) + printer, err := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *test.PrintOpts) if err != nil { t.Errorf("in %s, unexpected error: %#v", test.Name, err) } @@ -314,7 +314,7 @@ func TestBadPrinter(t *testing.T) { {"unknown format", &printers.PrintOptions{OutputFormatType: "anUnknownFormat", OutputFormatArgument: "", AllowMissingKeys: false}, fmt.Errorf("output format \"anUnknownFormat\" not recognized")}, } for _, test := range badPrinterTests { - _, err := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *test.PrintOpts) + _, err := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *test.PrintOpts) if err == nil || err.Error() != test.Error.Error() { t.Errorf("in %s, expect %s, got %s", test.Name, test.Error, err) } @@ -492,7 +492,7 @@ func TestNamePrinter(t *testing.T) { "pod/foo\npod/bar\n"}, } printOpts := &printers.PrintOptions{OutputFormatType: "name", AllowMissingKeys: false} - printer, _ := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *printOpts) + printer, _ := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *printOpts) for name, item := range tests { buff := &bytes.Buffer{} err := printer.PrintObj(item.obj, buff) @@ -3022,7 +3022,7 @@ func TestAllowMissingKeys(t *testing.T) { } for _, test := range tests { buf := bytes.NewBuffer([]byte{}) - printer, err := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *test.PrintOpts) + printer, err := printers.GetStandardPrinter(legacyscheme.Scheme, legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}, *test.PrintOpts) if err != nil { t.Errorf("in %s, unexpected error: %#v", test.Name, err) } diff --git a/pkg/registry/core/rest/storage_core.go b/pkg/registry/core/rest/storage_core.go index d085022aae..26fc0304f3 100644 --- a/pkg/registry/core/rest/storage_core.go +++ b/pkg/registry/core/rest/storage_core.go @@ -103,7 +103,7 @@ func (c LegacyRESTStorageProvider) NewLegacyRESTStorage(restOptionsGetter generi } var podDisruptionClient policyclient.PodDisruptionBudgetsGetter - if policyGroupVersion := (schema.GroupVersion{Group: "policy", Version: "v1beta1"}); legacyscheme.Registry.IsEnabledVersion(policyGroupVersion) { + if policyGroupVersion := (schema.GroupVersion{Group: "policy", Version: "v1beta1"}); legacyscheme.Registry.IsRegisteredVersion(policyGroupVersion) { var err error podDisruptionClient, err = policyclient.NewForConfig(c.LoopbackClientConfig) if err != nil { @@ -226,10 +226,10 @@ func (c LegacyRESTStorageProvider) NewLegacyRESTStorage(restOptionsGetter generi "componentStatuses": componentstatus.NewStorage(componentStatusStorage{c.StorageFactory}.serversToValidate), } - if legacyscheme.Registry.IsEnabledVersion(schema.GroupVersion{Group: "autoscaling", Version: "v1"}) { + if legacyscheme.Registry.IsRegisteredVersion(schema.GroupVersion{Group: "autoscaling", Version: "v1"}) { restStorageMap["replicationControllers/scale"] = controllerStorage.Scale } - if legacyscheme.Registry.IsEnabledVersion(schema.GroupVersion{Group: "policy", Version: "v1beta1"}) { + if legacyscheme.Registry.IsRegisteredVersion(schema.GroupVersion{Group: "policy", Version: "v1beta1"}) { restStorageMap["pods/eviction"] = podStorage.Eviction } if serviceAccountStorage.Token != nil { diff --git a/plugin/pkg/admission/eventratelimit/apis/eventratelimit/install/install.go b/plugin/pkg/admission/eventratelimit/apis/eventratelimit/install/install.go index 805cb579ff..6204bae968 100644 --- a/plugin/pkg/admission/eventratelimit/apis/eventratelimit/install/install.go +++ b/plugin/pkg/admission/eventratelimit/apis/eventratelimit/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: internalapi.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ versionedapi.SchemeGroupVersion.Version: versionedapi.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/plugin/pkg/admission/eventratelimit/config.go b/plugin/pkg/admission/eventratelimit/config.go index 993ac9ef44..5d27c7a59d 100644 --- a/plugin/pkg/admission/eventratelimit/config.go +++ b/plugin/pkg/admission/eventratelimit/config.go @@ -22,7 +22,6 @@ import ( "io/ioutil" "os" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -32,14 +31,13 @@ import ( ) var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) - scheme = runtime.NewScheme() - codecs = serializer.NewCodecFactory(scheme) + registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) + scheme = runtime.NewScheme() + codecs = serializer.NewCodecFactory(scheme) ) func init() { - install.Install(groupFactoryRegistry, registry, scheme) + install.Install(registry, scheme) } // LoadConfiguration loads the provided configuration. diff --git a/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction/install/install.go b/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction/install/install.go index bc4336a439..e81da6e64f 100644 --- a/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction/install/install.go +++ b/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: internalapi.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ versionedapi.SchemeGroupVersion.Version: versionedapi.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/plugin/pkg/admission/podtolerationrestriction/config.go b/plugin/pkg/admission/podtolerationrestriction/config.go index 49bcd070ba..8af06fbe0d 100644 --- a/plugin/pkg/admission/podtolerationrestriction/config.go +++ b/plugin/pkg/admission/podtolerationrestriction/config.go @@ -22,7 +22,6 @@ import ( "io/ioutil" "os" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -33,14 +32,13 @@ import ( ) var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) - scheme = runtime.NewScheme() - codecs = serializer.NewCodecFactory(scheme) + registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) + scheme = runtime.NewScheme() + codecs = serializer.NewCodecFactory(scheme) ) func init() { - install.Install(groupFactoryRegistry, registry, scheme) + install.Install(registry, scheme) } // LoadConfiguration loads the provided configuration. diff --git a/plugin/pkg/admission/resourcequota/apis/resourcequota/install/install.go b/plugin/pkg/admission/resourcequota/apis/resourcequota/install/install.go index aa28431ece..3958e4604e 100644 --- a/plugin/pkg/admission/resourcequota/apis/resourcequota/install/install.go +++ b/plugin/pkg/admission/resourcequota/apis/resourcequota/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: resourcequotaapi.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ resourcequotav1alpha1.SchemeGroupVersion.Version: resourcequotav1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/plugin/pkg/admission/resourcequota/config.go b/plugin/pkg/admission/resourcequota/config.go index d706a9afb5..513c1b29e4 100644 --- a/plugin/pkg/admission/resourcequota/config.go +++ b/plugin/pkg/admission/resourcequota/config.go @@ -22,7 +22,6 @@ import ( "io/ioutil" "os" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -32,14 +31,13 @@ import ( ) var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) - scheme = runtime.NewScheme() - codecs = serializer.NewCodecFactory(scheme) + registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) + scheme = runtime.NewScheme() + codecs = serializer.NewCodecFactory(scheme) ) func init() { - install.Install(groupFactoryRegistry, registry, scheme) + install.Install(registry, scheme) } // LoadConfiguration loads the provided configuration. diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go index 25cee84d2d..7df1a194fb 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go @@ -26,7 +26,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: apiextensions.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go index 0f9fd0de24..535b6a9020 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go @@ -24,7 +24,6 @@ import ( "github.com/golang/glog" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -53,10 +52,9 @@ import ( ) var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - Registry = registered.NewOrDie("") - Scheme = runtime.NewScheme() - Codecs = serializer.NewCodecFactory(Scheme) + Registry = registered.NewOrDie("") + Scheme = runtime.NewScheme() + Codecs = serializer.NewCodecFactory(Scheme) // if you modify this, make sure you update the crEncoder unversionedVersion = schema.GroupVersion{Group: "", Version: "v1"} @@ -71,7 +69,7 @@ var ( ) func init() { - install.Install(groupFactoryRegistry, Registry, Scheme) + install.Install(Registry, Scheme) // we need to add the options to empty v1 metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Group: "", Version: "v1"}) diff --git a/staging/src/k8s.io/apimachinery/pkg/api/testing/roundtrip/roundtrip.go b/staging/src/k8s.io/apimachinery/pkg/api/testing/roundtrip/roundtrip.go index 64b590e652..81e2110534 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/testing/roundtrip/roundtrip.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/testing/roundtrip/roundtrip.go @@ -33,7 +33,6 @@ import ( apimeta "k8s.io/apimachinery/pkg/api/meta" apitesting "k8s.io/apimachinery/pkg/api/testing" "k8s.io/apimachinery/pkg/api/testing/fuzzer" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metafuzzer "k8s.io/apimachinery/pkg/apis/meta/fuzzer" "k8s.io/apimachinery/pkg/runtime" @@ -45,15 +44,14 @@ import ( "k8s.io/apimachinery/pkg/util/sets" ) -type InstallFunc func(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) +type InstallFunc func(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) // RoundTripTestForAPIGroup is convenient to call from your install package to make sure that a "bare" install of your group provides // enough information to round trip func RoundTripTestForAPIGroup(t *testing.T, installFn InstallFunc, fuzzingFuncs fuzzer.FuzzerFuncs) { - groupFactoryRegistry := make(announced.APIGroupFactoryRegistry) registry := registered.NewOrDie("") scheme := runtime.NewScheme() - installFn(groupFactoryRegistry, registry, scheme) + installFn(registry, scheme) RoundTripTestForScheme(t, scheme, fuzzingFuncs) } @@ -72,10 +70,9 @@ func RoundTripTestForScheme(t *testing.T, scheme *runtime.Scheme, fuzzingFuncs f // RoundTripProtobufTestForAPIGroup is convenient to call from your install package to make sure that a "bare" install of your group provides // enough information to round trip func RoundTripProtobufTestForAPIGroup(t *testing.T, installFn InstallFunc, fuzzingFuncs fuzzer.FuzzerFuncs) { - groupFactoryRegistry := make(announced.APIGroupFactoryRegistry) registry := registered.NewOrDie("") scheme := runtime.NewScheme() - installFn(groupFactoryRegistry, registry, scheme) + installFn(registry, scheme) RoundTripProtobufTestForScheme(t, scheme, fuzzingFuncs) } diff --git a/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced.go b/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced.go deleted file mode 100644 index 4e38cc8c54..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package announced contains tools for announcing API group factories. This is -// distinct from registration (in the 'registered' package) in that it's safe -// to announce every possible group linked in, but only groups requested at -// runtime should be registered. This package contains both a registry, and -// factory code (which was formerly copy-pasta in every install package). -package announced - -import ( - "fmt" - - "k8s.io/apimachinery/pkg/apimachinery/registered" - "k8s.io/apimachinery/pkg/runtime" -) - -// APIGroupFactoryRegistry allows for groups and versions to announce themselves, -// which simply makes them available and doesn't take other actions. Later, -// users of the registry can select which groups and versions they'd actually -// like to register with an APIRegistrationManager. -// -// (Right now APIRegistrationManager has separate 'registration' and 'enabled' -// concepts-- APIGroupFactory is going to take over the former function; -// they will overlap until the refactoring is finished.) -// -// The key is the group name. After initialization, this should be treated as -// read-only. It is implemented as a map from group name to group factory, and -// it is safe to use this knowledge to manually pick out groups to register -// (e.g., for testing). -type APIGroupFactoryRegistry map[string]*GroupMetaFactory - -func (gar APIGroupFactoryRegistry) group(groupName string) *GroupMetaFactory { - gmf, ok := gar[groupName] - if !ok { - gmf = &GroupMetaFactory{VersionArgs: map[string]*GroupVersionFactoryArgs{}} - gar[groupName] = gmf - } - return gmf -} - -// AnnounceGroupVersion adds the particular arguments for this group version to the group factory. -func (gar APIGroupFactoryRegistry) AnnounceGroupVersion(gvf *GroupVersionFactoryArgs) error { - gmf := gar.group(gvf.GroupName) - if _, ok := gmf.VersionArgs[gvf.VersionName]; ok { - return fmt.Errorf("version %q in group %q has already been announced", gvf.VersionName, gvf.GroupName) - } - gmf.VersionArgs[gvf.VersionName] = gvf - return nil -} - -// AnnounceGroup adds the group-wide arguments to the group factory. -func (gar APIGroupFactoryRegistry) AnnounceGroup(args *GroupMetaFactoryArgs) error { - gmf := gar.group(args.GroupName) - if gmf.GroupArgs != nil { - return fmt.Errorf("group %q has already been announced", args.GroupName) - } - gmf.GroupArgs = args - return nil -} - -// RegisterAndEnableAll throws every factory at the specified API registration -// manager, and lets it decide which to register. (If you want to do this a la -// cart, you may look through gar itself-- it's just a map.) -func (gar APIGroupFactoryRegistry) RegisterAndEnableAll(m *registered.APIRegistrationManager, scheme *runtime.Scheme) error { - for groupName, gmf := range gar { - if err := gmf.Register(m); err != nil { - return fmt.Errorf("error registering %v: %v", groupName, err) - } - if err := gmf.Enable(m, scheme); err != nil { - return fmt.Errorf("error enabling %v: %v", groupName, err) - } - } - return nil -} - -// AnnouncePreconstructedFactory announces a factory which you've manually assembled. -// You may call this instead of calling AnnounceGroup and AnnounceGroupVersion. -func (gar APIGroupFactoryRegistry) AnnouncePreconstructedFactory(gmf *GroupMetaFactory) error { - name := gmf.GroupArgs.GroupName - if _, exists := gar[name]; exists { - return fmt.Errorf("the group %q has already been announced.", name) - } - gar[name] = gmf - return nil -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced_test.go b/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced_test.go deleted file mode 100644 index 95882e5df5..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/announced_test.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package announced - -import ( - "reflect" - "testing" - - "k8s.io/apimachinery/pkg/util/sets" -) - -func TestFactoryRegistry(t *testing.T) { - regA := make(APIGroupFactoryRegistry) - regB := make(APIGroupFactoryRegistry) - - if err := regA.AnnounceGroup(&GroupMetaFactoryArgs{ - GroupName: "foo", - VersionPreferenceOrder: []string{"v2", "v1"}, - RootScopedKinds: sets.NewString("namespaces"), - }); err != nil { - t.Fatalf("Unexpected error: %v", err) - } - if err := regA.AnnounceGroupVersion(&GroupVersionFactoryArgs{ - GroupName: "foo", - VersionName: "v1", - }); err != nil { - t.Fatalf("Unexpected error: %v", err) - } - if err := regA.AnnounceGroupVersion(&GroupVersionFactoryArgs{ - GroupName: "foo", - VersionName: "v2", - }); err != nil { - t.Fatalf("Unexpected error: %v", err) - } - - if err := regB.AnnouncePreconstructedFactory(NewGroupMetaFactory( - &GroupMetaFactoryArgs{ - GroupName: "foo", - VersionPreferenceOrder: []string{"v2", "v1"}, - RootScopedKinds: sets.NewString("namespaces"), - }, - VersionToSchemeFunc{"v1": nil, "v2": nil}, - )); err != nil { - t.Fatalf("Unexpected error: %v", err) - } - - if !reflect.DeepEqual(regA, regB) { - t.Errorf("Expected both ways of registering to be equivalent, but they were not.\n\n%#v\n\n%#v\n", regA, regB) - } -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/group_factory.go b/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/group_factory.go index 146aa61c5a..80dd381c4c 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/group_factory.go +++ b/staging/src/k8s.io/apimachinery/pkg/apimachinery/announced/group_factory.go @@ -72,33 +72,8 @@ func NewGroupMetaFactory(groupArgs *GroupMetaFactoryArgs, versions VersionToSche return gmf } -// Announce adds this Group factory to the global factory registry. It should -// only be called if you constructed the GroupMetaFactory yourself via -// NewGroupMetaFactory. -// Note that this will panic on an error, since it's expected that you'll be -// calling this at initialization time and any error is a result of a -// programmer importing the wrong set of packages. If this assumption doesn't -// work for you, just call DefaultGroupFactoryRegistry.AnnouncePreconstructedFactory -// yourself. -func (gmf *GroupMetaFactory) Announce(groupFactoryRegistry APIGroupFactoryRegistry) *GroupMetaFactory { - if err := groupFactoryRegistry.AnnouncePreconstructedFactory(gmf); err != nil { - panic(err) - } - return gmf -} - // GroupMetaFactory has the logic for actually assembling and registering a group. // -// There are two ways of obtaining one of these. -// 1. You can announce your group and versions separately, and then let the -// GroupFactoryRegistry assemble this object for you. (This allows group and -// versions to be imported separately, without referencing each other, to -// keep import trees small.) -// 2. You can call NewGroupMetaFactory(), which is mostly a drop-in replacement -// for the old, bad way of doing things. You can then call .Announce() to -// announce your constructed factory to any code that would like to do -// things the new, better way. -// // Note that GroupMetaFactory actually does construct GroupMeta objects, but // currently it does so in a way that's very entangled with an // APIRegistrationManager. It's a TODO item to cleanly separate that interface. @@ -112,13 +87,16 @@ type GroupMetaFactory struct { } // Register constructs the finalized prioritized version list and sanity checks -// the announced group & versions. Then it calls register. -func (gmf *GroupMetaFactory) Register(m *registered.APIRegistrationManager) error { +// the registered group & versions. Then it calls register. +func (gmf *GroupMetaFactory) Register(m *registered.APIRegistrationManager, scheme *runtime.Scheme) error { if gmf.GroupArgs == nil { - return fmt.Errorf("partially announced groups are not allowed, only got versions: %#v", gmf.VersionArgs) + return fmt.Errorf("partially registered groups are not allowed, only got versions: %#v", gmf.VersionArgs) } if len(gmf.VersionArgs) == 0 { - return fmt.Errorf("group %v announced but no versions announced", gmf.GroupArgs.GroupName) + return fmt.Errorf("group %v registered but no versions registered", gmf.GroupArgs.GroupName) + } + if m.IsRegistered(gmf.GroupArgs.GroupName) { + return fmt.Errorf("the group %q has already been registered.", gmf.GroupArgs.GroupName) } pvSet := sets.NewString(gmf.GroupArgs.VersionPreferenceOrder...) @@ -152,54 +130,18 @@ func (gmf *GroupMetaFactory) Register(m *registered.APIRegistrationManager) erro glog.Warningf("group %v has multiple unprioritized versions: %#v. They will have an arbitrary preference order!", gmf.GroupArgs.GroupName, unprioritizedVersions) } if pvSet.Len() != 0 { - return fmt.Errorf("group %v has versions in the priority list that were never announced: %s", gmf.GroupArgs.GroupName, pvSet) + return fmt.Errorf("group %v has versions in the priority list that were never registered: %s", gmf.GroupArgs.GroupName, pvSet) } prioritizedVersions = append(prioritizedVersions, unprioritizedVersions...) m.RegisterVersions(prioritizedVersions) gmf.prioritizedVersionList = prioritizedVersions - return nil -} -func (gmf *GroupMetaFactory) newRESTMapper(scheme *runtime.Scheme, externalVersions []schema.GroupVersion, groupMeta *apimachinery.GroupMeta) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString() - if gmf.GroupArgs.RootScopedKinds != nil { - rootScoped = gmf.GroupArgs.RootScopedKinds - } - ignoredKinds := sets.NewString() - if gmf.GroupArgs.IgnoredKinds != nil { - ignoredKinds = gmf.GroupArgs.IgnoredKinds - } - - mapper := meta.NewDefaultRESTMapper(externalVersions, groupMeta.InterfacesFor) - for _, gv := range externalVersions { - for kind := range scheme.KnownTypes(gv) { - if ignoredKinds.Has(kind) { - continue - } - scope := meta.RESTScopeNamespace - if rootScoped.Has(kind) { - scope = meta.RESTScopeRoot - } - mapper.Add(gv.WithKind(kind), scope) - } - } - - return mapper -} - -// Enable enables group versions that are allowed, adds methods to the scheme, etc. -func (gmf *GroupMetaFactory) Enable(m *registered.APIRegistrationManager, scheme *runtime.Scheme) error { externalVersions := []schema.GroupVersion{} for _, v := range gmf.prioritizedVersionList { if !m.IsAllowedVersion(v) { continue } externalVersions = append(externalVersions, v) - if err := m.EnableVersions(v); err != nil { - return err - } gmf.VersionArgs[v.Version].AddToScheme(scheme) } if len(externalVersions) == 0 { @@ -237,18 +179,34 @@ func (gmf *GroupMetaFactory) Enable(m *registered.APIRegistrationManager, scheme return err } return nil + } -// RegisterAndEnable is provided only to allow this code to get added in multiple steps. -// It's really bad that this is called in init() methods, but supporting this -// temporarily lets us do the change incrementally. -func (gmf *GroupMetaFactory) RegisterAndEnable(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) error { - if err := gmf.Register(registry); err != nil { - return err +func (gmf *GroupMetaFactory) newRESTMapper(scheme *runtime.Scheme, externalVersions []schema.GroupVersion, groupMeta *apimachinery.GroupMeta) meta.RESTMapper { + // the list of kinds that are scoped at the root of the api hierarchy + // if a kind is not enumerated here, it is assumed to have a namespace scope + rootScoped := sets.NewString() + if gmf.GroupArgs.RootScopedKinds != nil { + rootScoped = gmf.GroupArgs.RootScopedKinds } - if err := gmf.Enable(registry, scheme); err != nil { - return err + ignoredKinds := sets.NewString() + if gmf.GroupArgs.IgnoredKinds != nil { + ignoredKinds = gmf.GroupArgs.IgnoredKinds } - return nil + mapper := meta.NewDefaultRESTMapper(externalVersions, groupMeta.InterfacesFor) + for _, gv := range externalVersions { + for kind := range scheme.KnownTypes(gv) { + if ignoredKinds.Has(kind) { + continue + } + scope := meta.RESTScopeNamespace + if rootScoped.Has(kind) { + scope = meta.RESTScopeRoot + } + mapper.Add(gv.WithKind(kind), scope) + } + } + + return mapper } diff --git a/staging/src/k8s.io/apimachinery/pkg/apimachinery/registered/registered.go b/staging/src/k8s.io/apimachinery/pkg/apimachinery/registered/registered.go index 0da94f50f6..aa9c483a2f 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apimachinery/registered/registered.go +++ b/staging/src/k8s.io/apimachinery/pkg/apimachinery/registered/registered.go @@ -42,11 +42,6 @@ type APIRegistrationManager struct { // registeredGroupVersions stores all API group versions for which RegisterGroup is called. registeredVersions map[schema.GroupVersion]struct{} - // enabledVersions represents all enabled API versions. It should be a - // subset of registeredVersions. Please call EnableVersions() to add - // enabled versions. - enabledVersions map[schema.GroupVersion]struct{} - // map of group meta for all groups. groupMetaMap map[string]*apimachinery.GroupMeta @@ -63,7 +58,6 @@ type APIRegistrationManager struct { func NewAPIRegistrationManager(kubeAPIVersions string) (*APIRegistrationManager, error) { m := &APIRegistrationManager{ registeredVersions: map[schema.GroupVersion]struct{}{}, - enabledVersions: map[schema.GroupVersion]struct{}{}, groupMetaMap: map[string]*apimachinery.GroupMeta{}, envRequestedVersions: []schema.GroupVersion{}, } @@ -106,23 +100,6 @@ func (m *APIRegistrationManager) RegisterGroup(groupMeta apimachinery.GroupMeta) return nil } -// EnableVersions adds the versions for the given group to the list of enabled versions. -// Note that the caller should call RegisterGroup before calling this method. -// The caller of this function is responsible to add the versions to scheme and RESTMapper. -func (m *APIRegistrationManager) EnableVersions(versions ...schema.GroupVersion) error { - var unregisteredVersions []schema.GroupVersion - for _, v := range versions { - if _, found := m.registeredVersions[v]; !found { - unregisteredVersions = append(unregisteredVersions, v) - } - m.enabledVersions[v] = struct{}{} - } - if len(unregisteredVersions) != 0 { - return fmt.Errorf("Please register versions before enabling them: %v", unregisteredVersions) - } - return nil -} - // IsAllowedVersion returns if the version is allowed by the KUBE_API_VERSIONS // environment variable. If the environment variable is empty, then it always // returns true. @@ -138,42 +115,6 @@ func (m *APIRegistrationManager) IsAllowedVersion(v schema.GroupVersion) bool { return false } -// IsEnabledVersion returns if a version is enabled. -func (m *APIRegistrationManager) IsEnabledVersion(v schema.GroupVersion) bool { - _, found := m.enabledVersions[v] - return found -} - -// EnabledVersions returns all enabled versions. Groups are randomly ordered, but versions within groups -// are priority order from best to worst -func (m *APIRegistrationManager) EnabledVersions() []schema.GroupVersion { - ret := []schema.GroupVersion{} - for _, groupMeta := range m.groupMetaMap { - for _, version := range groupMeta.GroupVersions { - if m.IsEnabledVersion(version) { - ret = append(ret, version) - } - } - } - return ret -} - -// EnabledVersionsForGroup returns all enabled versions for a group in order of best to worst -func (m *APIRegistrationManager) EnabledVersionsForGroup(group string) []schema.GroupVersion { - groupMeta, ok := m.groupMetaMap[group] - if !ok { - return []schema.GroupVersion{} - } - - ret := []schema.GroupVersion{} - for _, version := range groupMeta.GroupVersions { - if m.IsEnabledVersion(version) { - ret = append(ret, version) - } - } - return ret -} - // Group returns the metadata of a group if the group is registered, otherwise // an error is returned. func (m *APIRegistrationManager) Group(group string) (*apimachinery.GroupMeta, error) { @@ -197,11 +138,32 @@ func (m *APIRegistrationManager) IsRegisteredVersion(v schema.GroupVersion) bool return found } -// RegisteredGroupVersions returns all registered group versions. +// RegisteredGroupVersions returns all registered group versions. Groups are randomly ordered, but versions within groups +// are priority order from best to worst func (m *APIRegistrationManager) RegisteredGroupVersions() []schema.GroupVersion { ret := []schema.GroupVersion{} - for groupVersion := range m.registeredVersions { - ret = append(ret, groupVersion) + for _, groupMeta := range m.groupMetaMap { + for _, version := range groupMeta.GroupVersions { + if m.IsRegisteredVersion(version) { + ret = append(ret, version) + } + } + } + return ret +} + +// RegisteredVersionsForGroup returns all enabled versions for a group in order of best to worst +func (m *APIRegistrationManager) RegisteredVersionsForGroup(group string) []schema.GroupVersion { + groupMeta, ok := m.groupMetaMap[group] + if !ok { + return []schema.GroupVersion{} + } + + ret := []schema.GroupVersion{} + for _, version := range groupMeta.GroupVersions { + if m.IsRegisteredVersion(version) { + ret = append(ret, version) + } } return ret } @@ -239,11 +201,13 @@ func (m *APIRegistrationManager) GroupOrDie(group string) *apimachinery.GroupMet func (m *APIRegistrationManager) RESTMapper(versionPatterns ...schema.GroupVersion) meta.RESTMapper { unionMapper := meta.MultiRESTMapper{} unionedGroups := sets.NewString() - for enabledVersion := range m.enabledVersions { + for enabledVersion := range m.registeredVersions { if !unionedGroups.Has(enabledVersion.Group) { unionedGroups.Insert(enabledVersion.Group) groupMeta := m.groupMetaMap[enabledVersion.Group] - unionMapper = append(unionMapper, groupMeta.RESTMapper) + if groupMeta != nil { + unionMapper = append(unionMapper, groupMeta.RESTMapper) + } } } @@ -275,7 +239,7 @@ func (m *APIRegistrationManager) RESTMapper(versionPatterns ...schema.GroupVersi prioritizedGroupsSet := sets.NewString(prioritizedGroups...) remainingGroups := sets.String{} - for enabledVersion := range m.enabledVersions { + for enabledVersion := range m.registeredVersions { if !prioritizedGroupsSet.Has(enabledVersion.Group) { remainingGroups.Insert(enabledVersion.Group) } @@ -295,7 +259,7 @@ func (m *APIRegistrationManager) prioritiesForGroups(groups ...string) ([]schema kindPriority := []schema.GroupVersionKind{} for _, group := range groups { - availableVersions := m.EnabledVersionsForGroup(group) + availableVersions := m.RegisteredVersionsForGroup(group) if len(availableVersions) > 0 { resourcePriority = append(resourcePriority, availableVersions[0].WithResource(meta.AnyResource)) kindPriority = append(kindPriority, availableVersions[0].WithKind(meta.AnyKind)) @@ -328,7 +292,7 @@ func (m *APIRegistrationManager) AllPreferredGroupVersions() string { func (m *APIRegistrationManager) ValidateEnvRequestedVersions() []schema.GroupVersion { var missingVersions []schema.GroupVersion for _, v := range m.envRequestedVersions { - if _, found := m.enabledVersions[v]; !found { + if _, found := m.registeredVersions[v]; !found { missingVersions = append(missingVersions, v) } } diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install/install.go b/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install/install.go index c7ada70f91..ea8d23ace6 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install/install.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: testapigroup.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/install/install.go b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/install/install.go index bbb3eaf62c..e67059ea99 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/install/install.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: webhookadmission.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserver/install/install.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserver/install/install.go index 74951a755e..432b2c3754 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/apiserver/install/install.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserver/install/install.go @@ -26,7 +26,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: apiserver.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiserver/pkg/apis/audit/install/install.go b/staging/src/k8s.io/apiserver/pkg/apis/audit/install/install.go index 6acf7c5d12..d864d0ab49 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/audit/install/install.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/audit/install/install.go @@ -29,7 +29,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: audit.GroupName, @@ -42,7 +42,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiserver/pkg/apis/example/install/install.go b/staging/src/k8s.io/apiserver/pkg/apis/example/install/install.go index 5352108e78..bce46107f6 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/example/install/install.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/example/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: example.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ examplev1.SchemeGroupVersion.Version: examplev1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiserver/pkg/apis/example2/install/install.go b/staging/src/k8s.io/apiserver/pkg/apis/example2/install/install.go index 8980ecbefd..233e37ad54 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/example2/install/install.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/example2/install/install.go @@ -28,7 +28,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: example2.GroupName, @@ -38,7 +38,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ example2v1.SchemeGroupVersion.Version: example2v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/root_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/root_test.go index 8dc859de22..6378cc311e 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/root_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/root_test.go @@ -26,7 +26,6 @@ import ( "github.com/stretchr/testify/assert" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -38,10 +37,9 @@ import ( ) var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - registry = registered.NewOrDie("") - scheme = runtime.NewScheme() - codecs = serializer.NewCodecFactory(scheme) + registry = registered.NewOrDie("") + scheme = runtime.NewScheme() + codecs = serializer.NewCodecFactory(scheme) ) func init() { diff --git a/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go b/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go index 801d784143..df25a3964f 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go @@ -139,6 +139,7 @@ func TestParseRuntimeConfig(t *testing.T) { }, } for index, test := range testCases { + t.Log(registry.RegisteredGroupVersions()) actualDisablers, err := MergeAPIResourceConfigs(test.defaultResourceConfig(), test.runtimeConfig, registry) if err == nil && test.err { t.Fatalf("expected error for test case: %v", index) @@ -168,10 +169,12 @@ func newFakeRegistry() *registered.APIRegistrationManager { registry := registered.NewOrDie("") registry.RegisterGroup(apimachinery.GroupMeta{ - GroupVersion: apiv1.SchemeGroupVersion, + GroupVersion: apiv1.SchemeGroupVersion, + GroupVersions: []schema.GroupVersion{apiv1.SchemeGroupVersion}, }) registry.RegisterGroup(apimachinery.GroupMeta{ - GroupVersion: extensionsapiv1beta1.SchemeGroupVersion, + GroupVersion: extensionsapiv1beta1.SchemeGroupVersion, + GroupVersions: []schema.GroupVersion{extensionsapiv1beta1.SchemeGroupVersion}, }) registry.RegisterVersions([]schema.GroupVersion{apiv1.SchemeGroupVersion, extensionsapiv1beta1.SchemeGroupVersion}) return registry diff --git a/staging/src/k8s.io/apiserver/pkg/server/storage/storage_factory_test.go b/staging/src/k8s.io/apiserver/pkg/server/storage/storage_factory_test.go index abccce32f7..f1a0f978bd 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/storage/storage_factory_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/storage/storage_factory_test.go @@ -21,7 +21,6 @@ import ( "reflect" "testing" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -37,7 +36,6 @@ var ( v1GroupVersion = schema.GroupVersion{Group: "", Version: "v1"} registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) - announce = make(announced.APIGroupFactoryRegistry) scheme = runtime.NewScheme() codecs = serializer.NewCodecFactory(scheme) parameterCodec = runtime.NewParameterCodec(scheme) @@ -53,7 +51,7 @@ func init() { &metav1.APIResourceList{}, ) - exampleinstall.Install(announce, registry, scheme) + exampleinstall.Install(registry, scheme) } type fakeNegotiater struct { @@ -119,8 +117,7 @@ func TestConfigurableStorageFactory(t *testing.T) { func TestUpdateEtcdOverrides(t *testing.T) { registry := registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) - announced := make(announced.APIGroupFactoryRegistry) - exampleinstall.Install(announced, registry, scheme) + exampleinstall.Install(registry, scheme) testCases := []struct { resource schema.GroupResource diff --git a/staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go b/staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go index 6893e834eb..4712f07997 100755 --- a/staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go @@ -48,7 +48,7 @@ func NewGenericWebhook(registry *registered.APIRegistrationManager, codecFactory func newGenericWebhook(registry *registered.APIRegistrationManager, codecFactory serializer.CodecFactory, kubeConfigFile string, groupVersions []schema.GroupVersion, initialBackoff, requestTimeout time.Duration) (*GenericWebhook, error) { for _, groupVersion := range groupVersions { - if !registry.IsEnabledVersion(groupVersion) { + if !registry.IsRegisteredVersion(groupVersion) { return nil, fmt.Errorf("webhook plugin requires enabling extension resource: %s", groupVersion) } } diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/audit/log/backend_test.go b/staging/src/k8s.io/apiserver/plugin/pkg/audit/log/backend_test.go index 44f01a0c66..491972061e 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/audit/log/backend_test.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/audit/log/backend_test.go @@ -18,7 +18,6 @@ package log import ( "bytes" - "fmt" "reflect" "regexp" "testing" @@ -26,7 +25,6 @@ import ( "github.com/pborman/uuid" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -40,17 +38,13 @@ import ( // NOTE: Copied from webhook backend to register auditv1beta1 to scheme var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - registry = registered.NewOrDie("") + registry = registered.NewOrDie("") ) func init() { allGVs := []schema.GroupVersion{auditv1beta1.SchemeGroupVersion} registry.RegisterVersions(allGVs) - if err := registry.EnableVersions(allGVs...); err != nil { - panic(fmt.Sprintf("failed to enable version %v", allGVs)) - } - install.Install(groupFactoryRegistry, registry, audit.Scheme) + install.Install(registry, audit.Scheme) } func TestLogEventsLegacy(t *testing.T) { diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go index eb2abada96..517395b845 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go @@ -18,10 +18,8 @@ limitations under the License. package webhook import ( - "fmt" "time" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime/schema" auditinternal "k8s.io/apiserver/pkg/apis/audit" @@ -46,7 +44,6 @@ var ( // NOTE: Copied from other webhook implementations // // Can we make these passable to NewGenericWebhook? - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) // TODO(audit): figure out a general way to let the client choose their preferred version registry = registered.NewOrDie("") ) @@ -54,10 +51,7 @@ var ( func init() { allGVs := []schema.GroupVersion{auditv1alpha1.SchemeGroupVersion, auditv1beta1.SchemeGroupVersion} registry.RegisterVersions(allGVs) - if err := registry.EnableVersions(allGVs...); err != nil { - panic(fmt.Sprintf("failed to enable version %v", allGVs)) - } - install.Install(groupFactoryRegistry, registry, audit.Scheme) + install.Install(registry, audit.Scheme) } func loadWebhook(configFile string, groupVersion schema.GroupVersion, initialBackoff time.Duration) (*webhook.GenericWebhook, error) { diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go index c735a0aa40..26f350d2b0 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go @@ -18,7 +18,6 @@ limitations under the License. package webhook import ( - "fmt" "time" "github.com/golang/glog" @@ -121,9 +120,6 @@ var registry = registered.NewOrDie("") func init() { registry.RegisterVersions(groupVersions) - if err := registry.EnableVersions(groupVersions...); err != nil { - panic(fmt.Sprintf("failed to enable version %v", groupVersions)) - } } // tokenReviewInterfaceFromKubeconfig builds a client from the specified kubeconfig file, diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go index d00e65be52..c0253bb89a 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go @@ -242,9 +242,6 @@ var registry = registered.NewOrDie("") func init() { registry.RegisterVersions(groupVersions) - if err := registry.EnableVersions(groupVersions...); err != nil { - panic(fmt.Sprintf("failed to enable version %v", groupVersions)) - } } // subjectAccessReviewInterfaceFromKubeconfig builds a client from the specified kubeconfig file, diff --git a/staging/src/k8s.io/client-go/pkg/apis/clientauthentication/install/install.go b/staging/src/k8s.io/client-go/pkg/apis/clientauthentication/install/install.go index 40093e97f5..f1b5ddebb4 100644 --- a/staging/src/k8s.io/client-go/pkg/apis/clientauthentication/install/install.go +++ b/staging/src/k8s.io/client-go/pkg/apis/clientauthentication/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: clientauthentication.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go b/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go index b5182d690f..307cab45bc 100644 --- a/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go +++ b/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: example.SchemeGroupVersion.Group, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go b/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go index ef241a33f2..9fc20da1d0 100644 --- a/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go +++ b/staging/src/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: example2.SchemeGroupVersion.Group, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1.SchemeGroupVersion.Version: v1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install/install.go b/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install/install.go index e4149bd0d9..657134f380 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install/install.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: apiregistration.GroupName, @@ -39,7 +39,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1.SchemeGroupVersion.Version: v1.AddToScheme, v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme/scheme.go b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme/scheme.go index 39cd3e9f4f..9697953a0a 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme/scheme.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme/scheme.go @@ -17,7 +17,6 @@ limitations under the License. package scheme import ( - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -34,8 +33,6 @@ var ( // Codecs provides methods for retrieving codecs and serializers for specific // versions and content types. Codecs = serializer.NewCodecFactory(Scheme) - // groupFactoryRegistry is the APIGroupFactoryRegistry. - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) // Registry is an instance of an API registry. This is an interim step to start removing the idea of a global // API registry. Registry = registered.NewOrDie("") @@ -43,7 +40,7 @@ var ( func init() { AddToScheme(Scheme) - install.Install(groupFactoryRegistry, Registry, Scheme) + install.Install(Registry, Scheme) } // AddToScheme adds the types of this group into the given scheme. diff --git a/staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install/install.go b/staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install/install.go index 5bcfd9cd6a..dc1196bd1c 100644 --- a/staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install/install.go +++ b/staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: custom_metrics.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/metrics/pkg/apis/external_metrics/install/install.go b/staging/src/k8s.io/metrics/pkg/apis/external_metrics/install/install.go index 6effb7f3e3..a036007399 100644 --- a/staging/src/k8s.io/metrics/pkg/apis/external_metrics/install/install.go +++ b/staging/src/k8s.io/metrics/pkg/apis/external_metrics/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: external_metrics.GroupName, @@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/metrics/pkg/apis/metrics/install/install.go b/staging/src/k8s.io/metrics/pkg/apis/metrics/install/install.go index b3e6eb5181..a4301e8400 100644 --- a/staging/src/k8s.io/metrics/pkg/apis/metrics/install/install.go +++ b/staging/src/k8s.io/metrics/pkg/apis/metrics/install/install.go @@ -28,7 +28,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: metrics.GroupName, @@ -39,7 +39,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r announced.VersionToSchemeFunc{ v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/install/install.go b/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/install/install.go index 3c65d4be0e..74d0306819 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/install/install.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/install/install.go @@ -27,7 +27,7 @@ import ( ) // Install registers the API group and adds types to a scheme -func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { +func Install(registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: wardle.GroupName, @@ -39,7 +39,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, }, - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + ).Register(registry, scheme); err != nil { panic(err) } } diff --git a/staging/src/k8s.io/sample-apiserver/pkg/apiserver/apiserver.go b/staging/src/k8s.io/sample-apiserver/pkg/apiserver/apiserver.go index 75adaf44ec..9992ca682d 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/apiserver/apiserver.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/apiserver/apiserver.go @@ -17,7 +17,6 @@ limitations under the License. package apiserver import ( - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -36,14 +35,13 @@ import ( ) var ( - groupFactoryRegistry = make(announced.APIGroupFactoryRegistry) - registry = registered.NewOrDie("") - Scheme = runtime.NewScheme() - Codecs = serializer.NewCodecFactory(Scheme) + registry = registered.NewOrDie("") + Scheme = runtime.NewScheme() + Codecs = serializer.NewCodecFactory(Scheme) ) func init() { - install.Install(groupFactoryRegistry, registry, Scheme) + install.Install(registry, Scheme) // we need to add the options to empty v1 // TODO fix the server code to avoid this diff --git a/test/e2e/apps/daemon_set.go b/test/e2e/apps/daemon_set.go index d7e18e2403..0a1692f489 100644 --- a/test/e2e/apps/daemon_set.go +++ b/test/e2e/apps/daemon_set.go @@ -79,12 +79,12 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { } } if daemonsets, err := f.ClientSet.AppsV1().DaemonSets(f.Namespace.Name).List(metav1.ListOptions{}); err == nil { - framework.Logf("daemonset: %s", runtime.EncodeOrDie(legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), daemonsets)) + framework.Logf("daemonset: %s", runtime.EncodeOrDie(legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), daemonsets)) } else { framework.Logf("unable to dump daemonsets: %v", err) } if pods, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(metav1.ListOptions{}); err == nil { - framework.Logf("pods: %s", runtime.EncodeOrDie(legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), pods)) + framework.Logf("pods: %s", runtime.EncodeOrDie(legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.RegisteredGroupVersions()...), pods)) } else { framework.Logf("unable to dump pods: %v", err) }