Skip to content

Commit

Permalink
Merge pull request #52 from wzshiming/feat/decode-type-meta
Browse files Browse the repository at this point in the history
Public encoding.DecodeTypeMeta
  • Loading branch information
siyuanfoundation authored May 16, 2024
2 parents 4e919b5 + f3ea259 commit 4addb26
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Convert(codecs serializer.CodecFactory, inMediaType, outMediaType string, i
return nil, nil, fmt.Errorf("unsupported conversion: protobuf to kubernetes binary storage representation")
}

typeMeta, err := decodeTypeMeta(inMediaType, in)
typeMeta, err := DecodeTypeMeta(inMediaType, in)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func tryFindJson(in []byte) (*json.RawMessage, bool) {
// DecodeSummary decodes the TypeMeta, ContentEncoding and ContentType fields from the 'Unknown'
// protobuf envelope of the given storage data.
func DecodeSummary(inMediaType string, in []byte, out io.Writer) error {
typeMeta, err := decodeTypeMeta(inMediaType, in)
typeMeta, err := DecodeTypeMeta(inMediaType, in)
if err != nil {
return err
}
Expand Down Expand Up @@ -220,8 +220,8 @@ func newCodec(codecs serializer.CodecFactory, typeMeta *runtime.TypeMeta, mediaT
return codec, nil
}

// getTypeMeta gets the TypeMeta from the given data, either as JSON or Protobuf.
func decodeTypeMeta(inMediaType string, in []byte) (*runtime.TypeMeta, error) {
// DecodeTypeMeta gets the TypeMeta from the given data, either as JSON or Protobuf.
func DecodeTypeMeta(inMediaType string, in []byte) (*runtime.TypeMeta, error) {
switch inMediaType {
case JsonMediaType:
return typeMetaFromJson(in)
Expand Down

0 comments on commit 4addb26

Please sign in to comment.