drop deprecated json/yaml newSerializers, use json.NewSerializerWithOptions instead

Signed-off-by: liyuerich <yue.li@daocloud.io>

Kubernetes-commit: 3c9309db463679c348934429d8487d190ed5e64a
This commit is contained in:
liyuerich 2024-05-29 19:00:00 +08:00 committed by Kubernetes Publisher
parent d6db44ddd4
commit 535f09400e
2 changed files with 2 additions and 2 deletions

View File

@ -348,7 +348,7 @@ func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *admiss
} }
var patchedJS []byte var patchedJS []byte
jsonSerializer := json.NewSerializer(json.DefaultMetaFactory, o.GetObjectCreater(), o.GetObjectTyper(), false) jsonSerializer := json.NewSerializerWithOptions(json.DefaultMetaFactory, o.GetObjectCreater(), o.GetObjectTyper(), json.SerializerOptions{})
switch result.PatchType { switch result.PatchType {
// VerifyAdmissionResponse normalizes to v1 patch types, regardless of the AdmissionReview version used // VerifyAdmissionResponse normalizes to v1 patch types, regardless of the AdmissionReview version used
case admissionv1.PatchTypeJSONPatch: case admissionv1.PatchTypeJSONPatch:

View File

@ -45,7 +45,7 @@ import (
// request body. The caller passes a callback which is called on each webhook POST. // request body. The caller passes a callback which is called on each webhook POST.
// The object passed to cb is of the same type as list. // The object passed to cb is of the same type as list.
func newWebhookHandler(t *testing.T, list runtime.Object, cb func(events runtime.Object)) http.Handler { func newWebhookHandler(t *testing.T, list runtime.Object, cb func(events runtime.Object)) http.Handler {
s := json.NewSerializer(json.DefaultMetaFactory, audit.Scheme, audit.Scheme, false) s := json.NewSerializerWithOptions(json.DefaultMetaFactory, audit.Scheme, audit.Scheme, json.SerializerOptions{})
return &testWebhookHandler{ return &testWebhookHandler{
t: t, t: t,
list: list, list: list,