From 535f09400e04501313c6d69d39ec9e9d24e1dfab Mon Sep 17 00:00:00 2001 From: liyuerich Date: Wed, 29 May 2024 19:00:00 +0800 Subject: [PATCH] drop deprecated json/yaml newSerializers, use json.NewSerializerWithOptions instead Signed-off-by: liyuerich Kubernetes-commit: 3c9309db463679c348934429d8487d190ed5e64a --- pkg/admission/plugin/webhook/mutating/dispatcher.go | 2 +- plugin/pkg/audit/webhook/webhook_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/admission/plugin/webhook/mutating/dispatcher.go b/pkg/admission/plugin/webhook/mutating/dispatcher.go index 5bf80237f..71328de7f 100644 --- a/pkg/admission/plugin/webhook/mutating/dispatcher.go +++ b/pkg/admission/plugin/webhook/mutating/dispatcher.go @@ -348,7 +348,7 @@ func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *admiss } 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 { // VerifyAdmissionResponse normalizes to v1 patch types, regardless of the AdmissionReview version used case admissionv1.PatchTypeJSONPatch: diff --git a/plugin/pkg/audit/webhook/webhook_test.go b/plugin/pkg/audit/webhook/webhook_test.go index a3a026da4..47d57eb67 100644 --- a/plugin/pkg/audit/webhook/webhook_test.go +++ b/plugin/pkg/audit/webhook/webhook_test.go @@ -45,7 +45,7 @@ import ( // 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. 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{ t: t, list: list,