parser

package
v0.0.0-...-310e069 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataHandlerFunc

type DataHandlerFunc func(r io.Reader, uf UpdateFile) error

DataHandlerFunc is a user provided update data stream handler. Parameter `r` is a decompressed data stream, `dt` holds current device type, `uf` contains basic information about update. The handler shall return nil if no errors occur.

type GenericParser

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

func (*GenericParser) ArchiveData

func (rp *GenericParser) ArchiveData(tw *tar.Writer, dst string) error

func (*GenericParser) ArchiveHeader

func (rp *GenericParser) ArchiveHeader(tw *tar.Writer, dstDir string, update *UpdateData) error

func (*GenericParser) Copy

func (rp *GenericParser) Copy() Parser

func (*GenericParser) GetMetadata

func (rp *GenericParser) GetMetadata() *metadata.Metadata

func (*GenericParser) GetUpdateFiles

func (rp *GenericParser) GetUpdateFiles() map[string]UpdateFile

func (*GenericParser) GetUpdateType

func (rp *GenericParser) GetUpdateType() *metadata.UpdateType

func (*GenericParser) ParseData

func (rp *GenericParser) ParseData(r io.Reader) error

ParseData for generic parser is used ONLY for validating the integrity of artifact file. The content of the update is "copied" to `ioutil.Discard` which causes all writes succeed without doing anything.

func (*GenericParser) ParseHeader

func (rp *GenericParser) ParseHeader(tr *tar.Reader, hdr *tar.Header, hPath string) error

type HeaderElems

type HeaderElems struct {
	Metadata []byte
	TypeInfo []byte
	Scripts  []string
}

type ParseManager

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

func NewParseManager

func NewParseManager() *ParseManager

func (*ParseManager) GetGeneric

func (p *ParseManager) GetGeneric() Parser

func (*ParseManager) GetRegistered

func (p *ParseManager) GetRegistered(parsingType string) (Parser, error)

func (*ParseManager) GetWorker

func (p *ParseManager) GetWorker(update string) (Parser, error)

func (*ParseManager) GetWorkers

func (p *ParseManager) GetWorkers() Workers

func (*ParseManager) PushWorker

func (p *ParseManager) PushWorker(parser Parser, update string) error

func (*ParseManager) Register

func (p *ParseManager) Register(parser Parser) error

func (*ParseManager) SetGeneric

func (p *ParseManager) SetGeneric(parser Parser)

type Parser

type Parser interface {
	Reader
	Writer
	Copy() Parser
}

type Reader

type Reader interface {
	ParseHeader(tr *tar.Reader, hdr *tar.Header, hPath string) error
	ParseData(r io.Reader) error

	GetUpdateType() *metadata.UpdateType
	GetUpdateFiles() map[string]UpdateFile
	GetMetadata() *metadata.Metadata
}

type RootfsParser

type RootfsParser struct {
	W         io.Writer       // output stream the update gets written to
	ScriptDir string          // output directory for scripts
	DataFunc  DataHandlerFunc // custom update data handler
	// contains filtered or unexported fields
}

RootfsParser handles updates of type 'rootfs-image'. The parser can be initialized setting `W` (io.Writer the update data gets written to), or `DataFunc` (user provided callback that handlers the update data stream).

func (*RootfsParser) ArchiveData

func (rp *RootfsParser) ArchiveData(tw *tar.Writer, dst string) error

func (*RootfsParser) ArchiveHeader

func (rp *RootfsParser) ArchiveHeader(tw *tar.Writer, dstDir string, update *UpdateData) error

func (*RootfsParser) Copy

func (rp *RootfsParser) Copy() Parser

func (*RootfsParser) GetMetadata

func (rp *RootfsParser) GetMetadata() *metadata.Metadata

func (*RootfsParser) GetUpdateFiles

func (rp *RootfsParser) GetUpdateFiles() map[string]UpdateFile

func (*RootfsParser) GetUpdateType

func (rp *RootfsParser) GetUpdateType() *metadata.UpdateType

func (*RootfsParser) ParseData

func (rp *RootfsParser) ParseData(r io.Reader) error

data files are stored in tar.gz format

func (*RootfsParser) ParseHeader

func (rp *RootfsParser) ParseHeader(tr *tar.Reader, hdr *tar.Header, hPath string) error

type UpdateData

type UpdateData struct {
	// path to directory containing update files; for `rootfs-image` type update
	// this will contain among the others `meta-data`, `type-info` and image files
	Path string
	// update data files
	DataFiles []string
	// type of update as in `type-info` file
	Type string
	// parser used for parsing update data
	P Parser
	// additional data used by specific parser
	Data interface{}
}

type UpdateFile

type UpdateFile struct {
	Name      string
	Path      string
	Size      int64
	Date      time.Time
	Checksum  []byte
	Signature []byte
}

type Workers

type Workers map[string]Parser

type Writer

type Writer interface {
	ArchiveHeader(tw *tar.Writer, dstDir string, update *UpdateData) error
	ArchiveData(tw *tar.Writer, dst string) error
}

Jump to

Keyboard shortcuts

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