Skip to content

Commit

Permalink
Wire serving codecs to CBOR feature gate.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benluddy authored and k8s-publishing-bot committed Nov 1, 2024
1 parent daaad09 commit 3b4250f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/runtime/serializer/cbor/cbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
},
}
}

0 comments on commit 3b4250f

Please sign in to comment.