Skip to content

Commit b24defa

Browse files
committed
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.
1 parent c427966 commit b24defa

File tree

1 file changed

+4
-0
lines changed
  • staging/src/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes

1 file changed

+4
-0
lines changed

staging/src/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ var Decode cbor.DecMode = func() cbor.DecMode {
8484
// When decoding an unrecognized tag to interface{}, return the decoded tag content
8585
// instead of the default, a cbor.Tag representing a (number, content) pair.
8686
UnrecognizedTagToAny: cbor.UnrecognizedTagContentToAny,
87+
88+
// For parity with JSON, strings can be decoded into time.Time if they are RFC 3339
89+
// timestamps.
90+
ByteStringToTime: cbor.ByteStringToTimeAllowed,
8791
}.DecMode()
8892
if err != nil {
8993
panic(err)

0 commit comments

Comments
 (0)