// NewDefaultingCodecForScheme is a convenience method for callers that are using a scheme. func NewDefaultingCodecForScheme( // TODO: I should be a scheme interface? scheme *runtime.Scheme, encoder runtime.Encoder, decoder runtime.Decoder, encodeVersion runtime.GroupVersioner, decodeVersion runtime.GroupVersioner, ) runtime.Codec { … } // NewCodec takes objects in their internal versions and converts them to external versions before // serializing them. It assumes the serializer provided to it only deals with external versions. // This class is also a serializer, but is generally used with a specific version. func NewCodec( encoder runtime.Encoder, decoder runtime.Decoder, convertor runtime.ObjectConvertor, creater runtime.ObjectCreater, typer runtime.ObjectTyper, defaulter runtime.ObjectDefaulter, encodeVersion runtime.GroupVersioner, decodeVersion runtime.GroupVersioner, originalSchemeName string, ) runtime.Codec { … } type codec … var _ … var identifiersMap … type codecIdentifier … // identifier computes Identifier of Encoder based on codec parameters. func identifier(encodeGV runtime.GroupVersioner, encoder runtime.Encoder) runtime.Identifier { … } // Decode attempts a decode of the object, then tries to convert it to the internal version. If into is provided and the decoding is // successful, the returned runtime.Object will be the value passed as into. Note that this may bypass conversion if you pass an // into that matches the serialized version. func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) { … } // EncodeWithAllocator ensures the provided object is output in the appropriate group and version, invoking // conversion if necessary. Unversioned objects (according to the ObjectTyper) are output as is. // In addition, it allows for providing a memory allocator for efficient memory usage during object serialization. func (c *codec) EncodeWithAllocator(obj runtime.Object, w io.Writer, memAlloc runtime.MemoryAllocator) error { … } // Encode ensures the provided object is output in the appropriate group and version, invoking // conversion if necessary. Unversioned objects (according to the ObjectTyper) are output as is. func (c *codec) Encode(obj runtime.Object, w io.Writer) error { … } func (c *codec) encode(obj runtime.Object, w io.Writer, memAlloc runtime.MemoryAllocator) error { … } func (c *codec) doEncode(obj runtime.Object, w io.Writer, memAlloc runtime.MemoryAllocator) error { … } // Identifier implements runtime.Encoder interface. func (c *codec) Identifier() runtime.Identifier { … }