apimachinery: k8s.io/apimachinery/pkg/util/yaml Index | Files

package yaml

import "k8s.io/apimachinery/pkg/util/yaml"

Index

Package Files

decoder.go

func GuessJSONStream Uses

func GuessJSONStream(r io.Reader, size int) (io.Reader, []byte, bool)

GuessJSONStream scans the provided reader up to size, looking for an open brace indicating this is JSON. It will return the bufio.Reader it creates for the consumer.

func NewDocumentDecoder Uses

func NewDocumentDecoder(r io.ReadCloser) io.ReadCloser

NewDocumentDecoder decodes YAML documents from the provided stream in chunks by converting each document (as defined by the YAML spec) into its own chunk. io.ErrShortBuffer will be returned if the entire buffer could not be read to assist the caller in framing the chunk.

func ToJSON Uses

func ToJSON(data []byte) ([]byte, error)

ToJSON converts a single YAML document into a JSON document or returns an error. If the document appears to be JSON the YAML decoding path is not used (so that error messages are JSON specific).

type JSONSyntaxError Uses

type JSONSyntaxError struct {
    Line int
    Err  error
}

func (JSONSyntaxError) Error Uses

func (e JSONSyntaxError) Error() string

type LineReader Uses

type LineReader struct {
    // contains filtered or unexported fields
}

func (*LineReader) Read Uses

func (r *LineReader) Read() ([]byte, error)

Read returns a single line (with '\n' ended) from the underlying reader. An error is returned iff there is an error with the underlying reader.

type Reader Uses

type Reader interface {
    Read() ([]byte, error)
}

type YAMLDecoder Uses

type YAMLDecoder struct {
    // contains filtered or unexported fields
}

YAMLDecoder reads chunks of objects and returns ErrShortBuffer if the data is not sufficient.

func (*YAMLDecoder) Close Uses

func (d *YAMLDecoder) Close() error

func (*YAMLDecoder) Read Uses

func (d *YAMLDecoder) Read(data []byte) (n int, err error)

Read reads the previous slice into the buffer, or attempts to read the next chunk. TODO: switch to readline approach.

type YAMLOrJSONDecoder Uses

type YAMLOrJSONDecoder struct {
    // contains filtered or unexported fields
}

YAMLOrJSONDecoder attempts to decode a stream of JSON documents or YAML documents by sniffing for a leading { character.

func NewYAMLOrJSONDecoder Uses

func NewYAMLOrJSONDecoder(r io.Reader, bufferSize int) *YAMLOrJSONDecoder

NewYAMLOrJSONDecoder returns a decoder that will process YAML documents or JSON documents from the given reader as a stream. bufferSize determines how far into the stream the decoder will look to figure out whether this is a JSON stream (has whitespace followed by an open brace).

func (*YAMLOrJSONDecoder) Decode Uses

func (d *YAMLOrJSONDecoder) Decode(into interface{}) error

Decode unmarshals the next object from the underlying stream into the provide object, or returns an error.

type YAMLReader Uses

type YAMLReader struct {
    // contains filtered or unexported fields
}

func NewYAMLReader Uses

func NewYAMLReader(r *bufio.Reader) *YAMLReader

func (*YAMLReader) Read Uses

func (r *YAMLReader) Read() ([]byte, error)

Read returns a full YAML document.

type YAMLSyntaxError Uses

type YAMLSyntaxError struct {
    // contains filtered or unexported fields
}

func (YAMLSyntaxError) Error Uses

func (e YAMLSyntaxError) Error() string

type YAMLToJSONDecoder Uses

type YAMLToJSONDecoder struct {
    // contains filtered or unexported fields
}

YAMLToJSONDecoder decodes YAML documents from an io.Reader by separating individual documents. It first converts the YAML body to JSON, then unmarshals the JSON.

func NewYAMLToJSONDecoder Uses

func NewYAMLToJSONDecoder(r io.Reader) *YAMLToJSONDecoder

NewYAMLToJSONDecoder decodes YAML documents from the provided stream in chunks by converting each document (as defined by the YAML spec) into its own chunk, converting it to JSON via yaml.YAMLToJSON, and then passing it to json.Decoder.

func (*YAMLToJSONDecoder) Decode Uses

func (d *YAMLToJSONDecoder) Decode(into interface{}) error

Decode reads a YAML document as JSON from the stream or returns an error. The decoding rules match json.Unmarshal, not yaml.Unmarshal.

Package yaml imports 10 packages (graph) and is imported by 394 packages. Updated 2019-03-28. Refresh now. Tools for package owners.