mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Switch API objects to not register per version codecs
Remove Codec from versionInterfaces in meta (RESTMapper is now agnostic to codec and serialization). Register api/latest.Codecs as the codec factory and use latest.Codecs.LegacyCodec(version) as an equvialent to the previous codec.
This commit is contained in:
@@ -17,7 +17,12 @@ limitations under the License.
|
||||
package latest
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/api/v1"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer/json"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer/versioning"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
_ "k8s.io/kubernetes/plugin/pkg/scheduler/api/v1"
|
||||
)
|
||||
|
||||
// Version is the string that represents the current external default version.
|
||||
@@ -33,6 +38,10 @@ const OldestVersion = "v1"
|
||||
var Versions = []string{"v1"}
|
||||
|
||||
// Codec is the default codec for serializing input that should use
|
||||
// the latest supported version.
|
||||
// This codec can decode any object that Kubernetes is aware of.
|
||||
var Codec = v1.Codec
|
||||
// the latest supported version. It supports JSON by default.
|
||||
var Codec = versioning.NewCodecForScheme(
|
||||
api.Scheme,
|
||||
json.NewSerializer(json.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme), true),
|
||||
[]unversioned.GroupVersion{{Version: Version}},
|
||||
[]unversioned.GroupVersion{{Version: runtime.APIVersionInternal}},
|
||||
)
|
||||
|
||||
@@ -26,9 +26,12 @@ var Scheme = runtime.NewScheme()
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
// TODO this should be in the "scheduler" group
|
||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""}
|
||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: runtime.APIVersionInternal}
|
||||
|
||||
func init() {
|
||||
if err := Scheme.AddIgnoredConversionType(&unversioned.TypeMeta{}, &unversioned.TypeMeta{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
Scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Policy{},
|
||||
)
|
||||
|
||||
@@ -18,7 +18,6 @@ package v1
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
@@ -26,9 +25,6 @@ import (
|
||||
// TODO this should be in the "scheduler" group
|
||||
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(SchemeGroupVersion,
|
||||
&Policy{},
|
||||
|
||||
Reference in New Issue
Block a user