// NewSerializer creates a JSON serializer that handles encoding versioned objects into the proper JSON form. If typer // is not nil, the object has the group, version, and kind fields set. // Deprecated: use NewSerializerWithOptions instead. func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper, pretty bool) *Serializer { … } // NewYAMLSerializer creates a YAML serializer that handles encoding versioned objects into the proper YAML form. If typer // is not nil, the object has the group, version, and kind fields set. This serializer supports only the subset of YAML that // matches JSON, and will error if constructs are used that do not serialize to JSON. // Deprecated: use NewSerializerWithOptions instead. func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper) *Serializer { … } // NewSerializerWithOptions creates a JSON/YAML serializer that handles encoding versioned objects into the proper JSON/YAML // form. If typer is not nil, the object has the group, version, and kind fields set. Options are copied into the Serializer // and are immutable. func NewSerializerWithOptions(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper, options SerializerOptions) *Serializer { … } // identifier computes Identifier of Encoder based on the given options. func identifier(options SerializerOptions) runtime.Identifier { … } type SerializerOptions … type Serializer … var _ … var _ … // gvkWithDefaults returns group kind and version defaulting from provided default func gvkWithDefaults(actual, defaultGVK schema.GroupVersionKind) schema.GroupVersionKind { … } // Decode attempts to convert the provided data into YAML or JSON, extract the stored schema kind, apply the provided default gvk, and then // load that data into an object matching the desired schema kind or the provided into. // If into is *runtime.Unknown, the raw data will be extracted and no decoding will be performed. // If into is not registered with the typer, then the object will be straight decoded using normal JSON/YAML unmarshalling. // If into is provided and the original data is not fully qualified with kind/version/group, the type of the into will be used to alter the returned gvk. // If into is nil or data's gvk different from into's gvk, it will generate a new Object with ObjectCreater.New(gvk) // On success or most errors, the method will return the calculated schema kind. // The gvk calculate priority will be originalData > default gvk > into func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) { … } // Encode serializes the provided object to the given writer. func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error { … } func (s *Serializer) doEncode(obj runtime.Object, w io.Writer) error { … } // IsStrict indicates whether the serializer // uses strict decoding or not func (s *Serializer) IsStrict() bool { … } func (s *Serializer) unmarshal(into runtime.Object, data, originalData []byte) (strictErrs []error, err error) { … } // Identifier implements runtime.Encoder interface. func (s *Serializer) Identifier() runtime.Identifier { … } // RecognizesData implements the RecognizingDecoder interface. func (s *Serializer) RecognizesData(data []byte) (ok, unknown bool, err error) { … } var Framer … type jsonFramer … // NewFrameWriter implements stream framing for this serializer func (jsonFramer) NewFrameWriter(w io.Writer) io.Writer { … } // NewFrameReader implements stream framing for this serializer func (jsonFramer) NewFrameReader(r io.ReadCloser) io.ReadCloser { … } var YAMLFramer … type yamlFramer … // NewFrameWriter implements stream framing for this serializer func (yamlFramer) NewFrameWriter(w io.Writer) io.Writer { … } // NewFrameReader implements stream framing for this serializer func (yamlFramer) NewFrameReader(r io.ReadCloser) io.ReadCloser { … } type yamlFrameWriter … // Write separates each document with the YAML document separator (`---` followed by line // break). Writers must write well formed YAML documents (include a final line break). func (w yamlFrameWriter) Write(data []byte) (n int, err error) { … }