mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +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:
@@ -26,7 +26,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
@@ -48,7 +47,7 @@ func TestCompatibility(
|
||||
) {
|
||||
|
||||
// Decode
|
||||
codec := runtime.CodecFor(api.Scheme, version)
|
||||
codec := api.Codecs.LegacyCodec(version)
|
||||
obj, err := runtime.Decode(codec, input)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
|
||||
@@ -59,9 +59,6 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source)
|
||||
func(q *resource.Quantity, c fuzz.Continue) {
|
||||
*q = *resource.NewQuantity(c.Int63n(1000), resource.DecimalExponent)
|
||||
},
|
||||
func(j *runtime.PluginBase, c fuzz.Continue) {
|
||||
// Do nothing; this struct has only a Kind field and it must stay blank in memory.
|
||||
},
|
||||
func(j *runtime.TypeMeta, c fuzz.Continue) {
|
||||
// We have to customize the randomization of TypeMetas because their
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
@@ -177,10 +174,8 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source)
|
||||
// TODO: uncomment when round trip starts from a versioned object
|
||||
if true { //c.RandBool() {
|
||||
*j = &runtime.Unknown{
|
||||
// apiVersion has rules now. Since it includes <group>/<version> and only `v1` can be bare,
|
||||
// then this must choose a valid format to deserialize
|
||||
TypeMeta: runtime.TypeMeta{Kind: "Something", APIVersion: "unknown.group/unknown"},
|
||||
RawJSON: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`),
|
||||
// We do not set TypeMeta here because it is not carried through a round trip
|
||||
RawJSON: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`),
|
||||
}
|
||||
} else {
|
||||
types := []runtime.Object{&api.Pod{}, &api.ReplicationController{}}
|
||||
|
||||
Reference in New Issue
Block a user