From 8d4bdb8e4e65279e00ee481e85c150671ad0715d Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Fri, 18 Dec 2015 23:24:47 +0100 Subject: [PATCH] API registration --- pkg/api/register.go | 22 +++++++++++++----- pkg/api/v1/register.go | 19 +++++++++++++++- pkg/api/v1beta3/register.go | 20 +++++++++++++++-- pkg/authorization/api/register.go | 21 ++++++++++++++++-- pkg/authorization/api/v1/register.go | 22 +++++++++++++++++- pkg/authorization/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/build/api/register.go | 21 ++++++++++++++++-- pkg/build/api/v1/register.go | 22 +++++++++++++++++- pkg/build/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/cmd/server/api/register.go | 17 +++++++++++++- pkg/cmd/server/api/v1/register.go | 24 +++++++++++++++++--- pkg/deploy/api/register.go | 21 ++++++++++++++++-- pkg/deploy/api/v1/register.go | 22 +++++++++++++++++- pkg/deploy/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/image/api/docker10/register.go | 22 +++++++++++++++++- pkg/image/api/dockerpre012/register.go | 22 +++++++++++++++++- pkg/image/api/register.go | 21 ++++++++++++++++-- pkg/image/api/v1/register.go | 22 +++++++++++++++++- pkg/image/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/oauth/api/register.go | 21 ++++++++++++++++-- pkg/oauth/api/v1/register.go | 22 +++++++++++++++++- pkg/oauth/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/project/api/register.go | 21 ++++++++++++++++-- pkg/project/api/v1/register.go | 22 +++++++++++++++++- pkg/project/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/route/api/register.go | 21 ++++++++++++++++-- pkg/route/api/v1/register.go | 26 ++++++++++++++++++++-- pkg/route/api/v1beta3/register.go | 24 +++++++++++++++++++- pkg/sdn/api/register.go | 21 ++++++++++++++++-- pkg/sdn/api/v1/register.go | 22 +++++++++++++++++- pkg/sdn/api/v1beta3/register.go | 22 +++++++++++++++++- pkg/template/api/register.go | 21 ++++++++++++++++-- pkg/template/api/v1/register.go | 27 ++++++++++++++++++++--- pkg/template/api/v1beta3/register.go | 27 ++++++++++++++++++++--- pkg/user/api/register.go | 21 ++++++++++++++++-- pkg/user/api/v1/register.go | 22 +++++++++++++++++- pkg/user/api/v1beta3/register.go | 22 +++++++++++++++++- 37 files changed, 753 insertions(+), 59 deletions(-) diff --git a/pkg/api/register.go b/pkg/api/register.go index da139f1ab52b..27821e69297a 100644 --- a/pkg/api/register.go +++ b/pkg/api/register.go @@ -1,7 +1,7 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" _ "github.com/openshift/origin/pkg/authorization/api" @@ -16,10 +16,22 @@ import ( _ "github.com/openshift/origin/pkg/user/api" ) -// Codec is the identity codec for this package - it can only convert itself -// to itself. -var Codec = runtime.CodecFor(api.Scheme, "") +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} func init() { - api.Scheme.AddKnownTypes("") + api.Scheme.AddKnownTypes(SchemeGroupVersion) } diff --git a/pkg/api/v1/register.go b/pkg/api/v1/register.go index c20df267079b..bb4e1d8951a5 100644 --- a/pkg/api/v1/register.go +++ b/pkg/api/v1/register.go @@ -2,6 +2,8 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" _ "github.com/openshift/origin/pkg/authorization/api/v1" @@ -16,8 +18,23 @@ import ( _ "github.com/openshift/origin/pkg/user/api/v1" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + // Codec encodes internal objects to the v1 scheme -var Codec = runtime.CodecFor(api.Scheme, "v1") +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) func init() { + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion) } diff --git a/pkg/api/v1beta3/register.go b/pkg/api/v1beta3/register.go index dbc907330229..8ca79b8f3b19 100644 --- a/pkg/api/v1beta3/register.go +++ b/pkg/api/v1beta3/register.go @@ -2,6 +2,8 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" _ "github.com/openshift/origin/pkg/authorization/api/v1beta3" @@ -16,9 +18,23 @@ import ( _ "github.com/openshift/origin/pkg/user/api/v1beta3" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + // Codec encodes internal objects to the v1beta3 scheme -var Codec = runtime.CodecFor(api.Scheme, "v1beta3") +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) func init() { - api.Scheme.AddKnownTypes("v1beta3") + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion) } diff --git a/pkg/authorization/api/register.go b/pkg/authorization/api/register.go index a45d4041671b..c3c93c632ca9 100644 --- a/pkg/authorization/api/register.go +++ b/pkg/authorization/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &Role{}, &RoleBinding{}, &Policy{}, diff --git a/pkg/authorization/api/v1/register.go b/pkg/authorization/api/v1/register.go index f58dbeb26051..a22e398b0ef7 100644 --- a/pkg/authorization/api/v1/register.go +++ b/pkg/authorization/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Role{}, &RoleBinding{}, &Policy{}, diff --git a/pkg/authorization/api/v1beta3/register.go b/pkg/authorization/api/v1beta3/register.go index 58fb7aac22f0..04f67adbf52f 100644 --- a/pkg/authorization/api/v1beta3/register.go +++ b/pkg/authorization/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Role{}, &RoleBinding{}, &Policy{}, diff --git a/pkg/build/api/register.go b/pkg/build/api/register.go index 4c22386443f9..c69079264527 100644 --- a/pkg/build/api/register.go +++ b/pkg/build/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &Build{}, &BuildList{}, &BuildConfig{}, diff --git a/pkg/build/api/v1/register.go b/pkg/build/api/v1/register.go index 146e06061b78..7a0840760547 100644 --- a/pkg/build/api/v1/register.go +++ b/pkg/build/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Build{}, &BuildList{}, &BuildConfig{}, diff --git a/pkg/build/api/v1beta3/register.go b/pkg/build/api/v1beta3/register.go index 2afe1a01ab55..52d8c5a21bc6 100644 --- a/pkg/build/api/v1beta3/register.go +++ b/pkg/build/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Build{}, &BuildList{}, &BuildConfig{}, diff --git a/pkg/cmd/server/api/register.go b/pkg/cmd/server/api/register.go index b93a1103b927..cddac1b24f38 100644 --- a/pkg/cmd/server/api/register.go +++ b/pkg/cmd/server/api/register.go @@ -1,13 +1,28 @@ package api import ( + "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. var Scheme = runtime.NewScheme() +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &MasterConfig{}, &NodeConfig{}, &SessionSecrets{}, diff --git a/pkg/cmd/server/api/v1/register.go b/pkg/cmd/server/api/v1/register.go index c588d6e61ca8..4a4d47b52fbb 100644 --- a/pkg/cmd/server/api/v1/register.go +++ b/pkg/cmd/server/api/v1/register.go @@ -1,14 +1,32 @@ package v1 import ( - "github.com/openshift/origin/pkg/cmd/server/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" + + "github.com/openshift/origin/pkg/cmd/server/api" ) -var Codec = runtime.CodecFor(api.Scheme, "v1") +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &MasterConfig{}, &NodeConfig{}, &SessionSecrets{}, diff --git a/pkg/deploy/api/register.go b/pkg/deploy/api/register.go index 6baff875982d..13c41a6cb574 100644 --- a/pkg/deploy/api/register.go +++ b/pkg/deploy/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &DeploymentConfig{}, &DeploymentConfigList{}, &DeploymentConfigRollback{}, diff --git a/pkg/deploy/api/v1/register.go b/pkg/deploy/api/v1/register.go index 3dd51cdb98b3..b4e2009d8b1c 100644 --- a/pkg/deploy/api/v1/register.go +++ b/pkg/deploy/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &DeploymentConfig{}, &DeploymentConfigList{}, &DeploymentConfigRollback{}, diff --git a/pkg/deploy/api/v1beta3/register.go b/pkg/deploy/api/v1beta3/register.go index 5ffafa47acff..d67916d948f3 100644 --- a/pkg/deploy/api/v1beta3/register.go +++ b/pkg/deploy/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &DeploymentConfig{}, &DeploymentConfigList{}, &DeploymentConfigRollback{}, diff --git a/pkg/image/api/docker10/register.go b/pkg/image/api/docker10/register.go index 6e055e73d8c7..64b00196e736 100644 --- a/pkg/image/api/docker10/register.go +++ b/pkg/image/api/docker10/register.go @@ -2,10 +2,30 @@ package docker10 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "1.0"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("1.0", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &DockerImage{}, ) } diff --git a/pkg/image/api/dockerpre012/register.go b/pkg/image/api/dockerpre012/register.go index 444b8f5fc97e..7d09a5ed45f6 100644 --- a/pkg/image/api/dockerpre012/register.go +++ b/pkg/image/api/dockerpre012/register.go @@ -2,10 +2,30 @@ package dockerpre012 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "pre012"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("pre012", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &DockerImage{}, ) } diff --git a/pkg/image/api/register.go b/pkg/image/api/register.go index 89bc9ef412f0..79b0627071a3 100644 --- a/pkg/image/api/register.go +++ b/pkg/image/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &Image{}, &ImageList{}, &ImageStream{}, diff --git a/pkg/image/api/v1/register.go b/pkg/image/api/v1/register.go index 8f121c24e77c..d99a407ae7ce 100644 --- a/pkg/image/api/v1/register.go +++ b/pkg/image/api/v1/register.go @@ -2,13 +2,33 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" _ "github.com/openshift/origin/pkg/image/api/docker10" _ "github.com/openshift/origin/pkg/image/api/dockerpre012" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Image{}, &ImageList{}, &ImageStream{}, diff --git a/pkg/image/api/v1beta3/register.go b/pkg/image/api/v1beta3/register.go index 93fc6ee57bae..dce115594532 100644 --- a/pkg/image/api/v1beta3/register.go +++ b/pkg/image/api/v1beta3/register.go @@ -2,13 +2,33 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" _ "github.com/openshift/origin/pkg/image/api/docker10" _ "github.com/openshift/origin/pkg/image/api/dockerpre012" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Image{}, &ImageList{}, &ImageStream{}, diff --git a/pkg/oauth/api/register.go b/pkg/oauth/api/register.go index 73be5a6aadb8..f55f88dea5e9 100644 --- a/pkg/oauth/api/register.go +++ b/pkg/oauth/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &OAuthAccessToken{}, &OAuthAccessTokenList{}, &OAuthAuthorizeToken{}, diff --git a/pkg/oauth/api/v1/register.go b/pkg/oauth/api/v1/register.go index bb083cf7dd2e..12699a9f4131 100644 --- a/pkg/oauth/api/v1/register.go +++ b/pkg/oauth/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &OAuthAccessToken{}, &OAuthAccessTokenList{}, &OAuthAuthorizeToken{}, diff --git a/pkg/oauth/api/v1beta3/register.go b/pkg/oauth/api/v1beta3/register.go index 7778d5b6b0a6..be602936dccc 100644 --- a/pkg/oauth/api/v1beta3/register.go +++ b/pkg/oauth/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &OAuthAccessToken{}, &OAuthAccessTokenList{}, &OAuthAuthorizeToken{}, diff --git a/pkg/project/api/register.go b/pkg/project/api/register.go index 4633ca593b23..82058905d2dd 100644 --- a/pkg/project/api/register.go +++ b/pkg/project/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &Project{}, &ProjectList{}, &ProjectRequest{}, diff --git a/pkg/project/api/v1/register.go b/pkg/project/api/v1/register.go index 157691ba27a9..c46cb2371999 100644 --- a/pkg/project/api/v1/register.go +++ b/pkg/project/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Project{}, &ProjectList{}, &ProjectRequest{}, diff --git a/pkg/project/api/v1beta3/register.go b/pkg/project/api/v1beta3/register.go index c16fafe66d85..c16a990f548a 100644 --- a/pkg/project/api/v1beta3/register.go +++ b/pkg/project/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Project{}, &ProjectList{}, &ProjectRequest{}, diff --git a/pkg/route/api/register.go b/pkg/route/api/register.go index 87b831caa909..cda1b9f487e5 100644 --- a/pkg/route/api/register.go +++ b/pkg/route/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &Route{}, &RouteList{}, ) diff --git a/pkg/route/api/v1/register.go b/pkg/route/api/v1/register.go index b2ec41c81232..6d91420c223f 100644 --- a/pkg/route/api/v1/register.go +++ b/pkg/route/api/v1/register.go @@ -1,9 +1,31 @@ package v1 -import "k8s.io/kubernetes/pkg/api" +import ( + "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion) func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Route{}, &RouteList{}, ) diff --git a/pkg/route/api/v1beta3/register.go b/pkg/route/api/v1beta3/register.go index 3609620de853..41842aba4d17 100644 --- a/pkg/route/api/v1beta3/register.go +++ b/pkg/route/api/v1beta3/register.go @@ -4,14 +4,36 @@ import ( "fmt" "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Route{}, &RouteList{}, ) +} +func addConversionFuncs() { // Add field conversion funcs. err := api.Scheme.AddFieldLabelConversionFunc("v1beta3", "Route", func(label, value string) (string, string, error) { diff --git a/pkg/sdn/api/register.go b/pkg/sdn/api/register.go index b4ccc58251e4..57e20d92d890 100644 --- a/pkg/sdn/api/register.go +++ b/pkg/sdn/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &ClusterNetwork{}, &ClusterNetworkList{}, &HostSubnet{}, diff --git a/pkg/sdn/api/v1/register.go b/pkg/sdn/api/v1/register.go index 91db5c6a2c63..ed4dcf1d3fb8 100644 --- a/pkg/sdn/api/v1/register.go +++ b/pkg/sdn/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &ClusterNetwork{}, &ClusterNetworkList{}, &HostSubnet{}, diff --git a/pkg/sdn/api/v1beta3/register.go b/pkg/sdn/api/v1beta3/register.go index 202d15387002..0cd4390a0da8 100644 --- a/pkg/sdn/api/v1beta3/register.go +++ b/pkg/sdn/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &ClusterNetwork{}, &ClusterNetworkList{}, &HostSubnet{}, diff --git a/pkg/template/api/register.go b/pkg/template/api/register.go index 0c1d061ea3b3..432f186f0c51 100644 --- a/pkg/template/api/register.go +++ b/pkg/template/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &Template{}, &TemplateList{}, ) diff --git a/pkg/template/api/v1/register.go b/pkg/template/api/v1/register.go index 01485642a128..579902843440 100644 --- a/pkg/template/api/v1/register.go +++ b/pkg/template/api/v1/register.go @@ -2,15 +2,36 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Template{}, &TemplateList{}, ) - api.Scheme.AddKnownTypeWithName("v1", "TemplateConfig", &Template{}) - api.Scheme.AddKnownTypeWithName("v1", "ProcessedTemplate", &Template{}) + + api.Scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("TemplateConfig"), &Template{}) + api.Scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("ProcessedTemplate"), &Template{}) } func (*Template) IsAnAPIObject() {} diff --git a/pkg/template/api/v1beta3/register.go b/pkg/template/api/v1beta3/register.go index e7f28aad7b19..437fd6a286c4 100644 --- a/pkg/template/api/v1beta3/register.go +++ b/pkg/template/api/v1beta3/register.go @@ -2,15 +2,36 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1beta3 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &Template{}, &TemplateList{}, ) - api.Scheme.AddKnownTypeWithName("v1beta3", "TemplateConfig", &Template{}) - api.Scheme.AddKnownTypeWithName("v1beta3", "ProcessedTemplate", &Template{}) + + api.Scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("TemplateConfig"), &Template{}) + api.Scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("ProcessedTemplate"), &Template{}) } func (*Template) IsAnAPIObject() {} diff --git a/pkg/user/api/register.go b/pkg/user/api/register.go index dbd3835f8e6c..66aae86ebc61 100644 --- a/pkg/user/api/register.go +++ b/pkg/user/api/register.go @@ -1,11 +1,28 @@ package api import ( - "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. +var Scheme = runtime.NewScheme() + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + func init() { - api.Scheme.AddKnownTypes("", + Scheme.AddKnownTypes(SchemeGroupVersion, &User{}, &UserList{}, &Identity{}, diff --git a/pkg/user/api/v1/register.go b/pkg/user/api/v1/register.go index af8d3fbda331..7e46cbb05a69 100644 --- a/pkg/user/api/v1/register.go +++ b/pkg/user/api/v1/register.go @@ -2,10 +2,30 @@ package v1 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &User{}, &UserList{}, &Identity{}, diff --git a/pkg/user/api/v1beta3/register.go b/pkg/user/api/v1beta3/register.go index 0a43933b0c97..19bda195d658 100644 --- a/pkg/user/api/v1beta3/register.go +++ b/pkg/user/api/v1beta3/register.go @@ -2,10 +2,30 @@ package v1beta3 import ( "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" ) +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"} + +// Codec encodes internal objects to the v1 scheme +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) + func init() { - api.Scheme.AddKnownTypes("v1beta3", + // Check if v1 is in the list of supported API versions. + if !registered.IsRegisteredAPIGroupVersion(SchemeGroupVersion) { + return + } + + // Register the API. + addKnownTypes() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes() { + api.Scheme.AddKnownTypes(SchemeGroupVersion, &User{}, &UserList{}, &Identity{},