metadata

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMetadataElemType indicates that element type is not supported.
	// The common case is when we are expecting a file with a given name, but
	// we have directory instead (and vice versa).
	ErrInvalidMetadataElemType = errors.New("Invalid artifact type")
	// ErrMissingMetadataElem is returned after scanning archive and detecting
	// that some element is missing (there are few which are required).
	ErrMissingMetadataElem = errors.New("Missing artifact")
	// ErrUnsupportedElement is returned after detecting file or directory,
	// which should not belong to artifact.
	ErrUnsupportedElement = errors.New("Unsupported artifact")
)
View Source
var ErrValidatingData = errors.New("error validating data")

ErrValidatingData is an error returned by Validate() in case of invalid data.

Functions

This section is empty.

Types

type ArtifactHeader

type ArtifactHeader map[string]DirEntry

ArtifactHeader is a filesystem structure containing information about all required elements of given Mender artifact.

func (ArtifactHeader) CheckHeaderStructure

func (ah ArtifactHeader) CheckHeaderStructure(headerDir string) error

CheckHeaderStructure checks if headerDir directory contains all needed files and sub-directories for creating Mender artifact.

type DirEntry

type DirEntry struct {
	// absolute path to file or directory
	Path string
	// specifies if entry is directory or file
	IsDir bool
	// some files are optional thus ew want to check if given entry is needed
	Required bool
}

DirEntry contains information about single enttry of artifact archive.

type Files

type Files struct {
	FileList []string `json:"files"`
}

Files represents the list of file names that make up the payload for given update.

func (Files) Validate

func (f Files) Validate() error

Validate checks format of Files.

func (*Files) Write

func (f *Files) Write(p []byte) (n int, err error)

type HeaderInfo

type HeaderInfo struct {
	Updates           []UpdateType `json:"updates"`
	CompatibleDevices []string     `json:"device_types_compatible"`
	ArtifactName      string       `json:"artifact_name"`
}

HeaderInfo contains information of numner and type of update files archived in Mender metadata archive.

func (HeaderInfo) Validate

func (hi HeaderInfo) Validate() error

Validate checks if header-info structure is correct.

func (*HeaderInfo) Write

func (hi *HeaderInfo) Write(p []byte) (n int, err error)

type Info

type Info struct {
	Format  string `json:"format"`
	Version int    `json:"version"`
}

Info contains the information about the format and the version of artifact archive.

func (Info) Validate

func (i Info) Validate() error

Validate performs sanity checks on artifact info.

func (*Info) Write

func (i *Info) Write(p []byte) (n int, err error)

type Metadata

type Metadata map[string]interface{}

Metadata contains artifacts metadata information. The exact metadata fields are user-defined and are not specified. The only requirement is that those must be stored in a for of JSON. The fields which must exist are update-type dependent. In case of `rootfs-update` image type, there are no additional fields required.

func (*Metadata) Map

func (m *Metadata) Map() map[string]interface{}

func (Metadata) Validate

func (m Metadata) Validate() error

Validate check corecness of artifacts metadata. Since the exact format is not specified validation always succeeds.

func (*Metadata) Write

func (m *Metadata) Write(p []byte) (n int, err error)

type TypeInfo

type TypeInfo struct {
	Type string `json:"type"`
}

TypeInfo provides information of type of individual updates archived in artifacts archive.

func (TypeInfo) Validate

func (ti TypeInfo) Validate() error

Validate validates corectness of TypeInfo.

func (*TypeInfo) Write

func (ti *TypeInfo) Write(p []byte) (n int, err error)

type UpdateType

type UpdateType struct {
	Type string `json:"type"`
}

UpdateType provides information about the type of update. At the moment we are supporting only "rootfs-image" type.

type WriteValidator

type WriteValidator interface {
	io.Writer
	Validate() error
}

WriteValidator is the interface that wraps the io.Writer interface and Validate method.

Jump to

Keyboard shortcuts

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