From 67aeda44c8fef2ded76eea0ec19e5a82acd9d9ad Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 19 Dec 2017 13:07:53 -0500 Subject: [PATCH] centralize legacy installation into core api group --- cmd/oc/oc.go | 2 + pkg/api/legacy/apigroups.go | 107 ++++++++++++++++++ pkg/api/legacy/install.go | 15 +++ pkg/apps/apis/apps/install/install.go | 3 +- .../apis/authorization/install/install.go | 5 +- pkg/build/apis/build/install/install.go | 3 +- pkg/image/apis/image/install/install.go | 5 +- pkg/network/apis/network/install/install.go | 5 +- pkg/oauth/apis/oauth/install/install.go | 5 +- pkg/project/apis/project/install/install.go | 5 +- pkg/quota/apis/quota/install/install.go | 5 +- pkg/route/apis/route/install/install.go | 3 +- pkg/security/apis/security/install/install.go | 5 +- pkg/template/apis/template/install/install.go | 5 +- pkg/user/apis/user/install/install.go | 5 +- 15 files changed, 136 insertions(+), 42 deletions(-) create mode 100644 pkg/api/legacy/apigroups.go diff --git a/cmd/oc/oc.go b/cmd/oc/oc.go index cddecd5781cc..4a607da6d6e4 100644 --- a/cmd/oc/oc.go +++ b/cmd/oc/oc.go @@ -15,6 +15,7 @@ import ( // install all APIs apiinstall "github.com/openshift/origin/pkg/api/install" + apilegacy "github.com/openshift/origin/pkg/api/legacy" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install" _ "k8s.io/kubernetes/pkg/apis/batch/install" _ "k8s.io/kubernetes/pkg/apis/core/install" @@ -33,6 +34,7 @@ func main() { } apiinstall.InstallAll(scheme.Scheme, scheme.GroupFactoryRegistry, scheme.Registry) + apilegacy.LegacyInstallAll(scheme.Scheme, scheme.Registry) basename := filepath.Base(os.Args[0]) command := cli.CommandFor(basename) diff --git a/pkg/api/legacy/apigroups.go b/pkg/api/legacy/apigroups.go new file mode 100644 index 000000000000..9c03c3a0f0df --- /dev/null +++ b/pkg/api/legacy/apigroups.go @@ -0,0 +1,107 @@ +package legacy + +import ( + "k8s.io/apimachinery/pkg/apimachinery/registered" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/sets" + + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" + authorizationapiv1 "github.com/openshift/origin/pkg/authorization/apis/authorization/v1" + buildapi "github.com/openshift/origin/pkg/build/apis/build" + buildapiv1 "github.com/openshift/origin/pkg/build/apis/build/v1" + imageapi "github.com/openshift/origin/pkg/image/apis/image" + imageapiv1 "github.com/openshift/origin/pkg/image/apis/image/v1" + networkapi "github.com/openshift/origin/pkg/network/apis/network" + networkapiv1 "github.com/openshift/origin/pkg/network/apis/network/v1" + oauthapi "github.com/openshift/origin/pkg/oauth/apis/oauth" + oauthapiv1 "github.com/openshift/origin/pkg/oauth/apis/oauth/v1" + projectapi "github.com/openshift/origin/pkg/project/apis/project" + projectapiv1 "github.com/openshift/origin/pkg/project/apis/project/v1" + quotaapi "github.com/openshift/origin/pkg/quota/apis/quota" + quotaapiv1 "github.com/openshift/origin/pkg/quota/apis/quota/v1" + routeapi "github.com/openshift/origin/pkg/route/apis/route" + routeapiv1 "github.com/openshift/origin/pkg/route/apis/route/v1" + securityapi "github.com/openshift/origin/pkg/security/apis/security" + securityapiv1 "github.com/openshift/origin/pkg/security/apis/security/v1" + templateapi "github.com/openshift/origin/pkg/template/apis/template" + templateapiv1 "github.com/openshift/origin/pkg/template/apis/template/v1" + userapi "github.com/openshift/origin/pkg/user/apis/user" + userapiv1 "github.com/openshift/origin/pkg/user/apis/user/v1" +) + +func InstallLegacyApps(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(appsapi.GroupName, appsapi.AddToSchemeInCoreGroup, appsapiv1.AddToSchemeInCoreGroup, sets.NewString(), registry, scheme) +} + +func InstallLegacyAuthorization(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(authorizationapi.GroupName, authorizationapi.AddToSchemeInCoreGroup, authorizationapiv1.AddToSchemeInCoreGroup, + sets.NewString("ClusterRole", "ClusterRoleBinding", "ClusterPolicy", "ClusterPolicyBinding", "ResourceAccessReviewResponse", "SubjectAccessReviewResponse"), + registry, scheme, + ) +} + +func InstallLegacyBuild(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(buildapi.GroupName, buildapi.AddToSchemeInCoreGroup, buildapiv1.AddToSchemeInCoreGroup, sets.NewString(), registry, scheme) +} + +func InstallLegacyImage(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(imageapi.GroupName, imageapi.AddToSchemeInCoreGroup, imageapiv1.AddToSchemeInCoreGroup, + sets.NewString("Image", "ImageSignature"), + registry, scheme, + ) +} + +func InstallLegacyNetwork(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(networkapi.GroupName, networkapi.AddToSchemeInCoreGroup, networkapiv1.AddToSchemeInCoreGroup, + sets.NewString("ClusterNetwork", "HostSubnet", "NetNamespace"), + registry, scheme, + ) +} + +func InstallLegacyOAuth(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(oauthapi.GroupName, oauthapi.AddToSchemeInCoreGroup, oauthapiv1.AddToSchemeInCoreGroup, + sets.NewString("OAuthAccessToken", "OAuthAuthorizeToken", "OAuthClient", "OAuthClientAuthorization"), + registry, scheme, + ) +} + +func InstallLegacyProject(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(projectapi.GroupName, projectapi.AddToSchemeInCoreGroup, projectapiv1.AddToSchemeInCoreGroup, + sets.NewString("Project", "ProjectRequest"), + registry, scheme, + ) +} + +func InstallLegacyQuota(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(quotaapi.GroupName, quotaapi.AddToSchemeInCoreGroup, quotaapiv1.AddToSchemeInCoreGroup, + sets.NewString("ClusterResourceQuota"), + registry, scheme, + ) +} + +func InstallLegacyRoute(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(routeapi.GroupName, routeapi.AddToSchemeInCoreGroup, routeapiv1.AddToSchemeInCoreGroup, sets.NewString(), registry, scheme) +} + +func InstallLegacySecurity(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(securityapi.GroupName, securityapi.AddToSchemeInCoreGroup, securityapiv1.AddToSchemeInCoreGroup, + sets.NewString("SecurityContextConstraints"), + registry, scheme, + ) +} + +func InstallLegacyTemplate(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(templateapi.GroupName, templateapi.AddToSchemeInCoreGroup, templateapiv1.AddToSchemeInCoreGroup, + sets.NewString("BrokerTemplateInstance"), + registry, scheme, + ) +} + +func InstallLegacyUser(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacy(userapi.GroupName, userapi.AddToSchemeInCoreGroup, userapiv1.AddToSchemeInCoreGroup, + sets.NewString("User", "Identity", "UserIdentityMapping", "Group"), + registry, scheme, + ) +} diff --git a/pkg/api/legacy/install.go b/pkg/api/legacy/install.go index b772b7362046..c1df6afc0e26 100644 --- a/pkg/api/legacy/install.go +++ b/pkg/api/legacy/install.go @@ -17,6 +17,21 @@ var ( coreV1 = schema.GroupVersion{Group: "", Version: "v1"} ) +func LegacyInstallAll(scheme *runtime.Scheme, registry *registered.APIRegistrationManager) { + InstallLegacyApps(scheme, registry) + InstallLegacyAuthorization(scheme, registry) + InstallLegacyBuild(scheme, registry) + InstallLegacyImage(scheme, registry) + InstallLegacyNetwork(scheme, registry) + InstallLegacyOAuth(scheme, registry) + InstallLegacyProject(scheme, registry) + InstallLegacyQuota(scheme, registry) + InstallLegacyRoute(scheme, registry) + InstallLegacySecurity(scheme, registry) + InstallLegacyTemplate(scheme, registry) + InstallLegacyUser(scheme, registry) +} + func InstallLegacy(group string, addToCore, addToCoreV1 func(*runtime.Scheme) error, rootScopedKinds sets.String, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { interfacesFor := interfacesForGroup(group) diff --git a/pkg/apps/apis/apps/install/install.go b/pkg/apps/apis/apps/install/install.go index 421eb95870e1..772b2d89241a 100644 --- a/pkg/apps/apis/apps/install/install.go +++ b/pkg/apps/apis/apps/install/install.go @@ -9,11 +9,10 @@ import ( legacy "github.com/openshift/origin/pkg/api/legacy" deployapi "github.com/openshift/origin/pkg/apps/apis/apps" deployapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - "k8s.io/apimachinery/pkg/util/sets" ) func init() { - legacy.InstallLegacy(deployapi.GroupName, deployapi.AddToSchemeInCoreGroup, deployapiv1.AddToSchemeInCoreGroup, sets.NewString(), legacyscheme.Registry, legacyscheme.Scheme) + legacy.InstallLegacyApps(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/authorization/apis/authorization/install/install.go b/pkg/authorization/apis/authorization/install/install.go index 95719af7b111..28d352a70bf1 100644 --- a/pkg/authorization/apis/authorization/install/install.go +++ b/pkg/authorization/apis/authorization/install/install.go @@ -14,10 +14,7 @@ import ( ) func init() { - legacy.InstallLegacy(authorizationapi.GroupName, authorizationapi.AddToSchemeInCoreGroup, authorizationapiv1.AddToSchemeInCoreGroup, - sets.NewString("ClusterRole", "ClusterRoleBinding", "ClusterPolicy", "ClusterPolicyBinding", "ResourceAccessReviewResponse", "SubjectAccessReviewResponse"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyAuthorization(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/build/apis/build/install/install.go b/pkg/build/apis/build/install/install.go index 9de560f3d884..fecff898a5b3 100644 --- a/pkg/build/apis/build/install/install.go +++ b/pkg/build/apis/build/install/install.go @@ -9,11 +9,10 @@ import ( "github.com/openshift/origin/pkg/api/legacy" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildapiv1 "github.com/openshift/origin/pkg/build/apis/build/v1" - "k8s.io/apimachinery/pkg/util/sets" ) func init() { - legacy.InstallLegacy(buildapi.GroupName, buildapi.AddToSchemeInCoreGroup, buildapiv1.AddToSchemeInCoreGroup, sets.NewString(), legacyscheme.Registry, legacyscheme.Scheme) + legacy.InstallLegacyBuild(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/image/apis/image/install/install.go b/pkg/image/apis/image/install/install.go index c6964dfceb15..ba85c8ab5b7e 100644 --- a/pkg/image/apis/image/install/install.go +++ b/pkg/image/apis/image/install/install.go @@ -15,10 +15,7 @@ import ( ) func init() { - legacy.InstallLegacy(imageapi.GroupName, imageapi.AddToSchemeInCoreGroup, imageapiv1.AddToSchemeInCoreGroup, - sets.NewString("Image", "ImageSignature"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyImage(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/network/apis/network/install/install.go b/pkg/network/apis/network/install/install.go index 250e6de6c503..2514b3fe2940 100644 --- a/pkg/network/apis/network/install/install.go +++ b/pkg/network/apis/network/install/install.go @@ -13,10 +13,7 @@ import ( ) func init() { - legacy.InstallLegacy(sdnapi.GroupName, sdnapi.AddToSchemeInCoreGroup, sdnapiv1.AddToSchemeInCoreGroup, - sets.NewString("ClusterNetwork", "HostSubnet", "NetNamespace"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyNetwork(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/oauth/apis/oauth/install/install.go b/pkg/oauth/apis/oauth/install/install.go index dd33361b1902..316522938bae 100644 --- a/pkg/oauth/apis/oauth/install/install.go +++ b/pkg/oauth/apis/oauth/install/install.go @@ -13,10 +13,7 @@ import ( ) func init() { - legacy.InstallLegacy(oauthapi.GroupName, oauthapi.AddToSchemeInCoreGroup, oauthapiv1.AddToSchemeInCoreGroup, - sets.NewString("OAuthAccessToken", "OAuthAuthorizeToken", "OAuthClient", "OAuthClientAuthorization"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyOAuth(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/project/apis/project/install/install.go b/pkg/project/apis/project/install/install.go index b3a2a0a0768a..461578cb68e9 100644 --- a/pkg/project/apis/project/install/install.go +++ b/pkg/project/apis/project/install/install.go @@ -13,10 +13,7 @@ import ( ) func init() { - legacy.InstallLegacy(projectapi.GroupName, projectapi.AddToSchemeInCoreGroup, projectapiv1.AddToSchemeInCoreGroup, - sets.NewString("Project", "ProjectRequest"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyProject(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/quota/apis/quota/install/install.go b/pkg/quota/apis/quota/install/install.go index bccca99bf9fe..f418dc2b3d5e 100644 --- a/pkg/quota/apis/quota/install/install.go +++ b/pkg/quota/apis/quota/install/install.go @@ -13,10 +13,7 @@ import ( ) func init() { - legacy.InstallLegacy(quotaapi.GroupName, quotaapi.AddToSchemeInCoreGroup, quotaapiv1.AddToSchemeInCoreGroup, - sets.NewString("ClusterResourceQuota"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyQuota(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/route/apis/route/install/install.go b/pkg/route/apis/route/install/install.go index 90ee075684b4..0dc0f908a7a9 100644 --- a/pkg/route/apis/route/install/install.go +++ b/pkg/route/apis/route/install/install.go @@ -9,11 +9,10 @@ import ( "github.com/openshift/origin/pkg/api/legacy" routeapi "github.com/openshift/origin/pkg/route/apis/route" routeapiv1 "github.com/openshift/origin/pkg/route/apis/route/v1" - "k8s.io/apimachinery/pkg/util/sets" ) func init() { - legacy.InstallLegacy(routeapi.GroupName, routeapi.AddToSchemeInCoreGroup, routeapiv1.AddToSchemeInCoreGroup, sets.NewString(), legacyscheme.Registry, legacyscheme.Scheme) + legacy.InstallLegacyRoute(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/security/apis/security/install/install.go b/pkg/security/apis/security/install/install.go index 649c13c5bfdc..76daca08ae8d 100644 --- a/pkg/security/apis/security/install/install.go +++ b/pkg/security/apis/security/install/install.go @@ -14,10 +14,7 @@ import ( func init() { Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) - legacy.InstallLegacy(securityapi.GroupName, securityapi.AddToSchemeInCoreGroup, securityapiv1.AddToSchemeInCoreGroup, - sets.NewString("SecurityContextConstraints"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacySecurity(legacyscheme.Scheme, legacyscheme.Registry) } // Install registers the API group and adds types to a scheme diff --git a/pkg/template/apis/template/install/install.go b/pkg/template/apis/template/install/install.go index 32ed9fe4d329..09bbddd9392d 100644 --- a/pkg/template/apis/template/install/install.go +++ b/pkg/template/apis/template/install/install.go @@ -13,10 +13,7 @@ import ( ) func init() { - legacy.InstallLegacy(templateapi.GroupName, templateapi.AddToSchemeInCoreGroup, templateapiv1.AddToSchemeInCoreGroup, - sets.NewString("BrokerTemplateInstance"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyTemplate(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) } diff --git a/pkg/user/apis/user/install/install.go b/pkg/user/apis/user/install/install.go index 9c7221774450..2683da5e3619 100644 --- a/pkg/user/apis/user/install/install.go +++ b/pkg/user/apis/user/install/install.go @@ -13,10 +13,7 @@ import ( ) func init() { - legacy.InstallLegacy(userapi.GroupName, userapi.AddToSchemeInCoreGroup, userapiv1.AddToSchemeInCoreGroup, - sets.NewString("User", "Identity", "UserIdentityMapping", "Group"), - legacyscheme.Registry, legacyscheme.Scheme, - ) + legacy.InstallLegacyUser(legacyscheme.Scheme, legacyscheme.Registry) Install(legacyscheme.GroupFactoryRegistry, legacyscheme.Registry, legacyscheme.Scheme) }