storage

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPlainParserNotImplemented = fmt.Errorf("PlainParser.FromBytes not implemented")

ErrPlainParserNotImplemented is returned when you try to use the PlainParser.FromBytes func.

Functions

func Load added in v0.0.4

func Load(p ReadParser, reader io.Reader) (interface{}, error)

Load loads data from the given io.Reader.

func LoadFromFile

func LoadFromFile(filename string, p ReadParser) (interface{}, error)

LoadFromFile loads data from the given file.

func Write added in v0.0.4

func Write(p WriteParser, value interface{}, originalValue interface{}, writer io.Writer, options ...ReadWriteOption) error

Write writes the value to the given io.Writer.

Types

type BasicMultiDocument added in v1.7.0

type BasicMultiDocument struct {
	Values []interface{}
	// contains filtered or unexported fields
}

BasicMultiDocument represents a multi-document file.

func (*BasicMultiDocument) Documents added in v1.7.0

func (d *BasicMultiDocument) Documents() []interface{}

Documents returns the documents that should be written to output.

func (BasicMultiDocument) OriginalRequired added in v1.7.0

func (d BasicMultiDocument) OriginalRequired() bool

OriginalRequired tells dasel if the parser requires the original value when converting to bytes.

func (*BasicMultiDocument) RealValue added in v1.7.0

func (d *BasicMultiDocument) RealValue() interface{}

RealValue returns the real value that dasel should use when processing data.

type BasicSingleDocument added in v1.7.0

type BasicSingleDocument struct {
	Value interface{}
	// contains filtered or unexported fields
}

BasicSingleDocument represents a single document file.

func (*BasicSingleDocument) Document added in v1.7.0

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

Document returns the document that should be written to output.

func (BasicSingleDocument) OriginalRequired added in v1.7.0

func (d BasicSingleDocument) OriginalRequired() bool

OriginalRequired tells dasel if the parser requires the original value when converting to bytes.

func (*BasicSingleDocument) RealValue added in v1.7.0

func (d *BasicSingleDocument) RealValue() interface{}

RealValue returns the real value that dasel should use when processing data.

type CSVDocument added in v1.3.0

type CSVDocument struct {
	Value   []map[string]interface{}
	Headers []string
	// contains filtered or unexported fields
}

CSVDocument represents a CSV file. This is required to keep headers in the expected order.

func (*CSVDocument) Documents added in v1.7.0

func (d *CSVDocument) Documents() []interface{}

Documents returns the documents that should be written to output.

func (CSVDocument) OriginalRequired added in v1.3.0

func (d CSVDocument) OriginalRequired() bool

OriginalRequired tells dasel if the parser requires the original value when converting to bytes.

func (*CSVDocument) RealValue added in v1.3.0

func (d *CSVDocument) RealValue() interface{}

RealValue returns the real value that dasel should use when processing data.

type CSVParser added in v1.3.0

type CSVParser struct {
}

CSVParser is a Parser implementation to handle yaml files.

func (*CSVParser) FromBytes added in v1.3.0

func (p *CSVParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some data that is represented by the given bytes.

func (*CSVParser) ToBytes added in v1.3.0

func (p *CSVParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type JSONParser

type JSONParser struct {
}

JSONParser is a Parser implementation to handle yaml files.

func (*JSONParser) FromBytes

func (p *JSONParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some data that is represented by the given bytes.

func (*JSONParser) ToBytes

func (p *JSONParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type MultiDocument added in v1.7.0

type MultiDocument interface {
	Documents() []interface{}
}

MultiDocument is a parser result that contains multiple documents.

type OptionKey added in v1.12.0

type OptionKey string

OptionKey is a defined type for keys within a ReadWriteOption.

const (
	// OptionIndent is the key used with IndentOption.
	OptionIndent OptionKey = "indent"
	// OptionPrettyPrint is the key used with PrettyPrintOption.
	OptionPrettyPrint OptionKey = "prettyPrint"
)

type OriginalRequired added in v1.2.0

type OriginalRequired interface {
	// OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
	OriginalRequired() bool
}

OriginalRequired can be used in conjunction with RealValue to allow parsers to be more intelligent with the data they read/write.

type Parser

type Parser interface {
	ReadParser
	WriteParser
}

Parser can be used to load and save files from/to disk.

type PlainParser added in v1.7.0

type PlainParser struct {
}

PlainParser is a Parser implementation to handle yaml files.

func (*PlainParser) FromBytes added in v1.7.0

func (p *PlainParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some data that is represented by the given bytes.

func (*PlainParser) ToBytes added in v1.7.0

func (p *PlainParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type ReadParser added in v1.7.0

type ReadParser interface {
	// FromBytes returns some data that is represented by the given bytes.
	FromBytes(byteData []byte) (interface{}, error)
}

ReadParser can be used to convert bytes to data.

func NewReadParserFromFilename added in v1.7.0

func NewReadParserFromFilename(filename string) (ReadParser, error)

NewReadParserFromFilename returns a ReadParser from the given filename.

func NewReadParserFromString added in v1.7.0

func NewReadParserFromString(parser string) (ReadParser, error)

NewReadParserFromString returns a ReadParser from the given parser name.

type ReadWriteOption added in v1.12.0

type ReadWriteOption struct {
	Key   OptionKey
	Value interface{}
}

ReadWriteOption is an option to be used when writing.

func IndentOption added in v1.12.0

func IndentOption(indent string) ReadWriteOption

IndentOption returns a write option that sets the given indent.

func PrettyPrintOption added in v1.12.0

func PrettyPrintOption(enabled bool) ReadWriteOption

PrettyPrintOption returns an option that enables or disables pretty printing.

type RealValue added in v1.2.0

type RealValue interface {
	// RealValue returns the real value that dasel should use when processing data.
	RealValue() interface{}
}

RealValue can be used in conjunction with OriginalRequired to allow parsers to be more intelligent with the data they read/write.

type SingleDocument added in v1.7.0

type SingleDocument interface {
	Document() interface{}
}

SingleDocument is a parser result that contains a single document.

type TOMLParser added in v0.0.5

type TOMLParser struct {
}

TOMLParser is a Parser implementation to handle toml files.

func (*TOMLParser) FromBytes added in v0.0.5

func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some data that is represented by the given bytes.

func (*TOMLParser) ToBytes added in v0.0.5

func (p *TOMLParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type UnknownParserErr

type UnknownParserErr struct {
	Parser string
}

UnknownParserErr is returned when an invalid parser name is given.

func (UnknownParserErr) Error

func (e UnknownParserErr) Error() string

Error returns the error message.

type WriteParser added in v1.7.0

type WriteParser interface {
	// ToBytes returns a slice of bytes that represents the given value.
	ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)
}

WriteParser can be used to convert data to bytes.

func NewWriteParserFromFilename added in v1.7.0

func NewWriteParserFromFilename(filename string) (WriteParser, error)

NewWriteParserFromFilename returns a WriteParser from the given filename.

func NewWriteParserFromString added in v1.7.0

func NewWriteParserFromString(parser string) (WriteParser, error)

NewWriteParserFromString returns a WriteParser from the given parser name.

type XMLParser added in v1.0.1

type XMLParser struct {
}

XMLParser is a Parser implementation to handle yaml files.

func (*XMLParser) FromBytes added in v1.0.1

func (p *XMLParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some data that is represented by the given bytes.

func (*XMLParser) ToBytes added in v1.0.1

func (p *XMLParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type YAMLParser

type YAMLParser struct {
}

YAMLParser is a Parser implementation to handle yaml files.

func (*YAMLParser) FromBytes

func (p *YAMLParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some data that is represented by the given bytes.

func (*YAMLParser) ToBytes

func (p *YAMLParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

Jump to

Keyboard shortcuts

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