From b24defacc5c05ee1c991d4c74b6325fa3f77460f Mon Sep 17 00:00:00 2001 From: Ben Luddy Date: Thu, 9 May 2024 14:37:06 -0400 Subject: [PATCH] Allow decoding RFC 3339 CBOR strings to time.Time. We had been relying on a bug in the library when it should have been rejected by default. That bug has been fixed and a new option added to opt-in to the behavior we need. --- .../pkg/runtime/serializer/cbor/internal/modes/decode.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go index 07c7474470c..f1290989754 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go @@ -84,6 +84,10 @@ var Decode cbor.DecMode = func() cbor.DecMode { // When decoding an unrecognized tag to interface{}, return the decoded tag content // instead of the default, a cbor.Tag representing a (number, content) pair. UnrecognizedTagToAny: cbor.UnrecognizedTagContentToAny, + + // For parity with JSON, strings can be decoded into time.Time if they are RFC 3339 + // timestamps. + ByteStringToTime: cbor.ByteStringToTimeAllowed, }.DecMode() if err != nil { panic(err)