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:
Clayton Coleman
2015-12-21 00:21:26 -05:00
parent 125ef6fbc8
commit c1d932e44a
54 changed files with 258 additions and 239 deletions

View File

@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/runtime"
)
func TestResourceVersioner(t *testing.T) {
@@ -51,7 +52,7 @@ func TestCodec(t *testing.T) {
daemonSet := extensions.DaemonSet{}
// We do want to use package registered rather than testapi here, because we
// want to test if the package install and package registered work as expected.
data, err := registered.GroupOrDie(extensions.GroupName).Codec.Encode(&daemonSet)
data, err := runtime.Encode(api.Codecs.LegacyCodec(registered.GroupOrDie(extensions.GroupName).GroupVersion), &daemonSet)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -101,9 +102,15 @@ func TestRESTMapper(t *testing.T) {
t.Errorf("incorrect groupVersion: %v", mapping)
}
<<<<<<< HEAD
interfaces, _ := registered.GroupOrDie(extensions.GroupName).InterfacesFor(version)
if mapping.Codec != interfaces.Codec {
t.Errorf("unexpected codec: %#v, expected: %#v", mapping, interfaces)
=======
interfaces, _ := latest.GroupOrDie(extensions.GroupName).InterfacesFor(version)
if mapping.ObjectConvertor != interfaces.ObjectConvertor {
t.Errorf("unexpected: %#v, expected: %#v", mapping, interfaces)
>>>>>>> e776ada... Switch API objects to not register per version codecs
}
rc := &extensions.HorizontalPodAutoscaler{ObjectMeta: api.ObjectMeta{Name: "foo"}}