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

@@ -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}},
)