From 3b4250faac5a9ef994851a3aedf07479ab2265bc Mon Sep 17 00:00:00 2001 From: Ben Luddy Date: Fri, 1 Nov 2024 16:05:32 -0400 Subject: [PATCH] Wire serving codecs to CBOR feature gate. Integration testing has to this point relied on patching serving codecs for built-in APIs. The test-only patching is removed and replaced by feature gated checks at runtime. Kubernetes-commit: 439d2f7b4028638b3d8d9261bb046c3ba8d9bfcb --- pkg/runtime/serializer/cbor/cbor.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/runtime/serializer/cbor/cbor.go b/pkg/runtime/serializer/cbor/cbor.go index 20fa7eb04..4d069a903 100644 --- a/pkg/runtime/serializer/cbor/cbor.go +++ b/pkg/runtime/serializer/cbor/cbor.go @@ -372,3 +372,18 @@ var selfDescribedCBOR = []byte{0xd9, 0xd9, 0xf7} func (s *serializer) RecognizesData(data []byte) (ok, unknown bool, err error) { return bytes.HasPrefix(data, selfDescribedCBOR), false, nil } + +// NewSerializerInfo returns a default SerializerInfo for CBOR using the given creater and typer. +func NewSerializerInfo(creater runtime.ObjectCreater, typer runtime.ObjectTyper) runtime.SerializerInfo { + return runtime.SerializerInfo{ + MediaType: "application/cbor", + MediaTypeType: "application", + MediaTypeSubType: "cbor", + Serializer: NewSerializer(creater, typer), + StrictSerializer: NewSerializer(creater, typer, Strict(true)), + StreamSerializer: &runtime.StreamSerializerInfo{ + Framer: NewFramer(), + Serializer: NewSerializer(creater, typer, Transcode(false)), + }, + } +}