yamlmeta

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewASTFromInterface

func NewASTFromInterface(val interface{}) interface{}

func NewASTFromInterfaceWithNoPosition added in v0.36.0

func NewASTFromInterfaceWithNoPosition(val interface{}) interface{}

func NewASTFromInterfaceWithPosition added in v0.35.0

func NewASTFromInterfaceWithPosition(val interface{}, defaultPosition *filepos.Position) interface{}

func NewGoFromAST added in v0.20.0

func NewGoFromAST(val interface{}) interface{}

func PlainMarshal

func PlainMarshal(in interface{}) ([]byte, error)

func PlainUnmarshal

func PlainUnmarshal(data []byte, out interface{}) error

Types

type Array

type Array struct {
	Type     Type
	Comments []*Comment
	Items    []*ArrayItem
	Position *filepos.Position
	// contains filtered or unexported fields
}

func (*Array) AddValue

func (a *Array) AddValue(val interface{}) error

func (*Array) Check added in v0.31.0

func (a *Array) Check() (chk TypeCheck)

func (*Array) DeepCopy

func (a *Array) DeepCopy() *Array

func (*Array) DeepCopyAsInterface

func (a *Array) DeepCopyAsInterface() interface{}

func (*Array) DeepCopyAsNode

func (a *Array) DeepCopyAsNode() Node

func (*Array) GetAnnotations

func (a *Array) GetAnnotations() interface{}

func (*Array) GetComments added in v0.36.0

func (a *Array) GetComments() []*Comment

func (*Array) GetPosition

func (a *Array) GetPosition() *filepos.Position

func (*Array) GetValues

func (a *Array) GetValues() []interface{}

func (*Array) MarshalJSON added in v0.15.0

func (a *Array) MarshalJSON() ([]byte, error)

func (*Array) MarshalYAML

func (a *Array) MarshalYAML() (interface{}, error)

func (*Array) ResetValue

func (a *Array) ResetValue()

func (*Array) SetAnnotations

func (a *Array) SetAnnotations(anns interface{})

func (*Array) SetPosition added in v0.32.0

func (a *Array) SetPosition(position *filepos.Position)

func (*Array) SetType added in v0.31.0

func (a *Array) SetType(t Type)

func (*Array) SetValue

func (a *Array) SetValue(val interface{}) error

func (*Array) ValueTypeAsString added in v0.32.0

func (a *Array) ValueTypeAsString() string

type ArrayItem

type ArrayItem struct {
	Type     Type
	Comments []*Comment
	Value    interface{}
	Position *filepos.Position
	// contains filtered or unexported fields
}

func (*ArrayItem) AddValue

func (ai *ArrayItem) AddValue(val interface{}) error

func (*ArrayItem) Check added in v0.31.0

func (ai *ArrayItem) Check() (chk TypeCheck)

func (*ArrayItem) DeepCopy

func (ai *ArrayItem) DeepCopy() *ArrayItem

func (*ArrayItem) DeepCopyAsInterface

func (ai *ArrayItem) DeepCopyAsInterface() interface{}

func (*ArrayItem) DeepCopyAsNode

func (ai *ArrayItem) DeepCopyAsNode() Node

func (*ArrayItem) GetAnnotations

func (ai *ArrayItem) GetAnnotations() interface{}

func (*ArrayItem) GetComments added in v0.36.0

func (ai *ArrayItem) GetComments() []*Comment

func (*ArrayItem) GetPosition

func (ai *ArrayItem) GetPosition() *filepos.Position

func (*ArrayItem) GetValues

func (ai *ArrayItem) GetValues() []interface{}

func (*ArrayItem) MarshalJSON added in v0.15.0

func (ai *ArrayItem) MarshalJSON() ([]byte, error)

func (*ArrayItem) MarshalYAML

func (ai *ArrayItem) MarshalYAML() (interface{}, error)

func (*ArrayItem) ResetValue

func (ai *ArrayItem) ResetValue()

func (*ArrayItem) SetAnnotations

func (ai *ArrayItem) SetAnnotations(anns interface{})

func (*ArrayItem) SetPosition added in v0.32.0

func (ai *ArrayItem) SetPosition(position *filepos.Position)

func (*ArrayItem) SetType added in v0.31.0

func (ai *ArrayItem) SetType(t Type)

func (*ArrayItem) SetValue

func (ai *ArrayItem) SetValue(val interface{}) error

func (*ArrayItem) Val added in v0.35.0

func (ai *ArrayItem) Val() interface{}

func (*ArrayItem) ValueTypeAsString added in v0.32.0

func (ai *ArrayItem) ValueTypeAsString() string

type Comment added in v0.36.0

type Comment struct {
	Data     string
	Position *filepos.Position
}

func (*Comment) DeepCopy added in v0.36.0

func (n *Comment) DeepCopy() *Comment

type CommentSlice added in v0.36.0

type CommentSlice []*Comment

func (CommentSlice) DeepCopy added in v0.36.0

func (s CommentSlice) DeepCopy() CommentSlice

type DocSetOpts added in v0.4.0

type DocSetOpts struct {
	WithoutComments bool
	Strict          bool
	// associatedName is typically a file name where data came from
	AssociatedName string
}

type Document

type Document struct {
	Type     Type
	Comments []*Comment
	Value    interface{}
	Position *filepos.Position
	// contains filtered or unexported fields
}

func (*Document) AddValue

func (d *Document) AddValue(val interface{}) error

func (*Document) AsInterface

func (d *Document) AsInterface() interface{}

func (*Document) AsYAMLBytes added in v0.20.0

func (d *Document) AsYAMLBytes() ([]byte, error)

func (*Document) Check added in v0.31.0

func (d *Document) Check() (chk TypeCheck)

func (*Document) DeepCopy

func (d *Document) DeepCopy() *Document

func (*Document) DeepCopyAsInterface

func (d *Document) DeepCopyAsInterface() interface{}

func (*Document) DeepCopyAsNode

func (d *Document) DeepCopyAsNode() Node

func (*Document) GetAnnotations

func (d *Document) GetAnnotations() interface{}

func (*Document) GetComments added in v0.36.0

func (d *Document) GetComments() []*Comment

func (*Document) GetPosition

func (d *Document) GetPosition() *filepos.Position

func (*Document) GetValues

func (d *Document) GetValues() []interface{}

func (*Document) IsEmpty

func (d *Document) IsEmpty() bool

func (*Document) MarshalJSON added in v0.15.0

func (d *Document) MarshalJSON() ([]byte, error)

func (*Document) MarshalYAML

func (d *Document) MarshalYAML() (interface{}, error)

func (*Document) ResetValue

func (d *Document) ResetValue()

func (*Document) SetAnnotations

func (d *Document) SetAnnotations(anns interface{})

func (*Document) SetPosition added in v0.32.0

func (d *Document) SetPosition(position *filepos.Position)

func (*Document) SetType added in v0.31.0

func (d *Document) SetType(t Type)

func (*Document) SetValue

func (d *Document) SetValue(val interface{}) error

func (*Document) Val added in v0.35.0

func (d *Document) Val() interface{}

func (*Document) ValueTypeAsString added in v0.32.0

func (d *Document) ValueTypeAsString() string

type DocumentPrinter added in v0.14.0

type DocumentPrinter interface {
	Print(*Document) error
}

type DocumentSet

type DocumentSet struct {
	Comments    []*Comment
	AllComments []*Comment

	Items    []*Document
	Position *filepos.Position
	// contains filtered or unexported fields
}

func NewDocumentSetFromBytes

func NewDocumentSetFromBytes(data []byte, opts DocSetOpts) (*DocumentSet, error)

func (*DocumentSet) AddValue

func (ds *DocumentSet) AddValue(val interface{}) error

func (*DocumentSet) AsBytes

func (ds *DocumentSet) AsBytes() ([]byte, error)

func (*DocumentSet) AsBytesWithPrinter added in v0.14.0

func (ds *DocumentSet) AsBytesWithPrinter(printerFunc func(io.Writer) DocumentPrinter) ([]byte, error)

func (*DocumentSet) AsSourceBytes

func (ds *DocumentSet) AsSourceBytes() ([]byte, bool)

AsSourceBytes() returns bytes used to make original DocumentSet. Any changes made to the DocumentSet are not reflected in any way

func (*DocumentSet) Check added in v0.31.0

func (ds *DocumentSet) Check() TypeCheck

func (*DocumentSet) DeepCopy

func (ds *DocumentSet) DeepCopy() *DocumentSet

func (*DocumentSet) DeepCopyAsInterface

func (ds *DocumentSet) DeepCopyAsInterface() interface{}

func (*DocumentSet) DeepCopyAsNode

func (ds *DocumentSet) DeepCopyAsNode() Node

func (*DocumentSet) GetAnnotations

func (ds *DocumentSet) GetAnnotations() interface{}

func (*DocumentSet) GetComments added in v0.36.0

func (ds *DocumentSet) GetComments() []*Comment

func (*DocumentSet) GetPosition

func (ds *DocumentSet) GetPosition() *filepos.Position

func (*DocumentSet) GetValues

func (ds *DocumentSet) GetValues() []interface{}

func (*DocumentSet) MarshalJSON added in v0.15.0

func (ds *DocumentSet) MarshalJSON() ([]byte, error)

func (*DocumentSet) MarshalYAML

func (ds *DocumentSet) MarshalYAML() (interface{}, error)

func (*DocumentSet) Print

func (ds *DocumentSet) Print(writer io.Writer)

func (*DocumentSet) ResetValue

func (ds *DocumentSet) ResetValue()

func (*DocumentSet) SetAnnotations

func (ds *DocumentSet) SetAnnotations(anns interface{})

func (*DocumentSet) SetPosition added in v0.32.0

func (ds *DocumentSet) SetPosition(position *filepos.Position)

func (*DocumentSet) SetValue

func (ds *DocumentSet) SetValue(val interface{}) error

func (*DocumentSet) ValueTypeAsString added in v0.32.0

func (ds *DocumentSet) ValueTypeAsString() string

type FilePositionPrinter added in v0.14.0

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

func NewFilePositionPrinter added in v0.14.0

func NewFilePositionPrinter(writer io.Writer) *FilePositionPrinter

func NewFilePositionPrinterWithOpts added in v0.14.0

func NewFilePositionPrinterWithOpts(writer io.Writer, opts FilePositionPrinterOpts) *FilePositionPrinter

func (*FilePositionPrinter) Print added in v0.14.0

func (p *FilePositionPrinter) Print(val interface{})

func (*FilePositionPrinter) PrintStr added in v0.14.0

func (p *FilePositionPrinter) PrintStr(val interface{}) string

type FilePositionPrinterOpts added in v0.14.0

type FilePositionPrinterOpts struct{}

type JSONPrinter added in v0.14.0

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

func NewJSONPrinter added in v0.14.0

func NewJSONPrinter(writer io.Writer) JSONPrinter

func (JSONPrinter) Print added in v0.14.0

func (p JSONPrinter) Print(item *Document) error

type Map

type Map struct {
	Type     Type
	Comments []*Comment
	Items    []*MapItem
	Position *filepos.Position
	// contains filtered or unexported fields
}

func (*Map) AddValue

func (m *Map) AddValue(val interface{}) error

func (*Map) Check added in v0.31.0

func (m *Map) Check() (chk TypeCheck)

func (*Map) DeepCopy

func (m *Map) DeepCopy() *Map

func (*Map) DeepCopyAsInterface

func (m *Map) DeepCopyAsInterface() interface{}

func (*Map) DeepCopyAsNode

func (m *Map) DeepCopyAsNode() Node

func (*Map) GetAnnotations

func (m *Map) GetAnnotations() interface{}

func (*Map) GetComments added in v0.36.0

func (m *Map) GetComments() []*Comment

func (*Map) GetPosition

func (m *Map) GetPosition() *filepos.Position

func (*Map) GetValues

func (m *Map) GetValues() []interface{}

func (*Map) MarshalJSON added in v0.15.0

func (m *Map) MarshalJSON() ([]byte, error)

func (*Map) MarshalYAML

func (m *Map) MarshalYAML() (interface{}, error)

func (*Map) ResetValue

func (m *Map) ResetValue()

func (*Map) SetAnnotations

func (m *Map) SetAnnotations(anns interface{})

func (*Map) SetPosition added in v0.32.0

func (m *Map) SetPosition(position *filepos.Position)

func (*Map) SetType added in v0.31.0

func (m *Map) SetType(t Type)

func (*Map) SetValue

func (m *Map) SetValue(val interface{}) error

func (*Map) ValueTypeAsString added in v0.32.0

func (m *Map) ValueTypeAsString() string

type MapItem

type MapItem struct {
	Type     Type
	Comments []*Comment
	Key      interface{}
	Value    interface{}
	Position *filepos.Position
	// contains filtered or unexported fields
}

func (*MapItem) AddValue

func (mi *MapItem) AddValue(val interface{}) error

func (*MapItem) Check added in v0.31.0

func (mi *MapItem) Check() (chk TypeCheck)

func (*MapItem) DeepCopy

func (mi *MapItem) DeepCopy() *MapItem

func (*MapItem) DeepCopyAsInterface

func (mi *MapItem) DeepCopyAsInterface() interface{}

func (*MapItem) DeepCopyAsNode

func (mi *MapItem) DeepCopyAsNode() Node

func (*MapItem) GetAnnotations

func (mi *MapItem) GetAnnotations() interface{}

func (*MapItem) GetComments added in v0.36.0

func (mi *MapItem) GetComments() []*Comment

func (*MapItem) GetPosition

func (mi *MapItem) GetPosition() *filepos.Position

func (*MapItem) GetValues

func (mi *MapItem) GetValues() []interface{}

func (*MapItem) MarshalJSON added in v0.15.0

func (mi *MapItem) MarshalJSON() ([]byte, error)

func (*MapItem) MarshalYAML

func (mi *MapItem) MarshalYAML() (interface{}, error)

func (*MapItem) ResetValue

func (mi *MapItem) ResetValue()

func (*MapItem) SetAnnotations

func (mi *MapItem) SetAnnotations(anns interface{})

func (*MapItem) SetPosition added in v0.32.0

func (mi *MapItem) SetPosition(position *filepos.Position)

func (*MapItem) SetType added in v0.31.0

func (mi *MapItem) SetType(t Type)

func (*MapItem) SetValue

func (mi *MapItem) SetValue(val interface{}) error

func (*MapItem) Val added in v0.35.0

func (mi *MapItem) Val() interface{}

func (*MapItem) ValueTypeAsString added in v0.32.0

func (mi *MapItem) ValueTypeAsString() string

type Node

type Node interface {
	GetPosition() *filepos.Position
	SetPosition(*filepos.Position)

	GetValues() []interface{} // ie children
	SetValue(interface{}) error
	AddValue(interface{}) error
	ResetValue()

	GetComments() []*Comment

	GetAnnotations() interface{}
	SetAnnotations(interface{})

	DeepCopyAsInterface() interface{}
	DeepCopyAsNode() Node

	Check() TypeCheck
	// contains filtered or unexported methods
}

type Parser

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

func NewParser

func NewParser(opts ParserOpts) *Parser

func (*Parser) ParseBytes

func (p *Parser) ParseBytes(data []byte, associatedName string) (*DocumentSet, error)

type ParserOpts added in v0.17.0

type ParserOpts struct {
	WithoutComments bool
	Strict          bool
}

type Printer

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

func NewPrinter

func NewPrinter(writer io.Writer) Printer

func NewPrinterWithOpts

func NewPrinterWithOpts(writer io.Writer, opts PrinterOpts) Printer

func (Printer) Print

func (p Printer) Print(val interface{})

func (Printer) PrintStr

func (p Printer) PrintStr(val interface{}) string

type PrinterOpts

type PrinterOpts struct {
	ExcludeRefs bool
}

type Scalar added in v0.31.0

type Scalar struct {
	Position *filepos.Position
	Value    interface{}
}

func (*Scalar) GetPosition added in v0.32.0

func (s *Scalar) GetPosition() *filepos.Position

func (*Scalar) GetValues added in v0.31.0

func (s *Scalar) GetValues() []interface{}

func (*Scalar) ValueTypeAsString added in v0.32.0

func (s *Scalar) ValueTypeAsString() string

type Type added in v0.31.0

type Type interface {
	AssignTypeTo(typeable Typeable) TypeCheck
	GetValueType() Type
	GetDefaultValue() interface{}
	CheckType(node TypeWithValues) TypeCheck
	GetDefinitionPosition() *filepos.Position
	String() string
}

type TypeCheck added in v0.31.0

type TypeCheck struct {
	Violations []error
}

func (TypeCheck) Error added in v0.32.0

func (tc TypeCheck) Error() string

func (*TypeCheck) HasViolations added in v0.31.0

func (tc *TypeCheck) HasViolations() bool

type TypeWithValues added in v0.31.0

type TypeWithValues interface {
	GetValues() []interface{}
	GetPosition() *filepos.Position
	ValueTypeAsString() string
}

type Typeable added in v0.31.0

type Typeable interface {
	TypeWithValues

	SetType(Type)
}

type ValueHoldingNode added in v0.35.0

type ValueHoldingNode interface {
	Node
	Val() interface{}
}

type WrappedFilePositionPrinter added in v0.14.0

type WrappedFilePositionPrinter struct {
	Printer *FilePositionPrinter
}

func (WrappedFilePositionPrinter) Print added in v0.14.0

func (p WrappedFilePositionPrinter) Print(item *Document) error

type YAMLPrinter added in v0.14.0

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

func NewYAMLPrinter added in v0.14.0

func NewYAMLPrinter(writer io.Writer) *YAMLPrinter

func (*YAMLPrinter) Print added in v0.14.0

func (p *YAMLPrinter) Print(item *Document) error

Directories

Path Synopsis
internal
yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL