Documentation
¶
Index ¶
- Constants
- Variables
- func GetPublic(private []byte) ([]byte, error)
- func GetRegisteredCompressorIds() []string
- func MarshalECDSASignature(r, s *big.Int) ([]byte, error)
- func RegisterCompressor(id string, compressor Compressor)
- func ToStream(m WriteValidator) ([]byte, error)
- func UnmarshalECDSASignature(sig []byte) (r, s *big.Int, e error)
- func UpdateDataPath(no int) string
- func UpdateHeaderPath(no int) string
- func UpdatePath(no int) string
- type ArtifactDepends
- type ArtifactProvides
- type Checksum
- type ChecksumStore
- func (c *ChecksumStore) Add(file string, sum []byte) error
- func (c *ChecksumStore) FilesNotMarked() []string
- func (c *ChecksumStore) Get(file string) ([]byte, error)
- func (c *ChecksumStore) GetAndMark(file string) ([]byte, error)
- func (c *ChecksumStore) GetRaw() []byte
- func (c *ChecksumStore) ReadRaw(data []byte) error
- type Compressor
- type CompressorGzip
- type CompressorLzma
- type CompressorNone
- type CompressorZstd
- type Crypto
- type ECDSA256
- type FileArchiver
- type Files
- type HeaderInfo
- func (hi *HeaderInfo) GetArtifactDepends() *ArtifactDepends
- func (hi *HeaderInfo) GetArtifactName() string
- func (hi *HeaderInfo) GetArtifactProvides() *ArtifactProvides
- func (hi *HeaderInfo) GetCompatibleDevices() []string
- func (hi *HeaderInfo) GetUpdates() []UpdateType
- func (h *HeaderInfo) UnmarshalJSON(b []byte) error
- func (hi HeaderInfo) Validate() error
- func (hi *HeaderInfo) Write(p []byte) (n int, err error)
- type HeaderInfoV3
- func (hi *HeaderInfoV3) GetArtifactDepends() *ArtifactDepends
- func (hi *HeaderInfoV3) GetArtifactName() string
- func (hi *HeaderInfoV3) GetArtifactProvides() *ArtifactProvides
- func (hi *HeaderInfoV3) GetCompatibleDevices() []string
- func (hi *HeaderInfoV3) GetUpdates() []UpdateType
- func (hi *HeaderInfoV3) Validate() error
- func (hi *HeaderInfoV3) Write(p []byte) (n int, err error)
- type HeaderInfoer
- type Info
- type Metadata
- type PKCS11Signer
- type PKISigner
- type RSA
- type Scripts
- type Signer
- type SigningMethod
- type StreamArchiver
- type TypeInfo
- type TypeInfoDepends
- type TypeInfoProvides
- type TypeInfoV3
- type UpdateType
- type Verifier
- type WriteValidator
Constants ¶
const ( HeaderDirectory = "headers" DataDirectory = "data" )
Variables ¶
var ErrCompatibleDevices error = errors.New(
"ArtifactDepends: Required field 'CompatibleDevices' not found",
)
var ErrValidatingData = errors.New("error validating data")
ErrValidatingData is an error returned by Validate() in case of invalid data.
Functions ¶
func GetRegisteredCompressorIds ¶
func GetRegisteredCompressorIds() []string
func RegisterCompressor ¶
func RegisterCompressor(id string, compressor Compressor)
func ToStream ¶
func ToStream(m WriteValidator) ([]byte, error)
func UpdateDataPath ¶
func UpdateHeaderPath ¶
func UpdatePath ¶
Types ¶
type ArtifactDepends ¶
type ArtifactDepends struct { ArtifactName []string `json:"artifact_name,omitempty"` CompatibleDevices []string `json:"device_type,omitempty"` ArtifactGroup []string `json:"artifact_group,omitempty"` }
func (*ArtifactDepends) UnmarshalJSON ¶
func (a *ArtifactDepends) UnmarshalJSON(b []byte) error
type ArtifactProvides ¶
type Checksum ¶
type Checksum struct {
// contains filtered or unexported fields
}
func NewWriterChecksum ¶
type ChecksumStore ¶
type ChecksumStore struct {
// contains filtered or unexported fields
}
func NewChecksumStore ¶
func NewChecksumStore() *ChecksumStore
func (*ChecksumStore) FilesNotMarked ¶
func (c *ChecksumStore) FilesNotMarked() []string
func (*ChecksumStore) GetAndMark ¶
func (c *ChecksumStore) GetAndMark(file string) ([]byte, error)
Same as Get(), but also marks the file as visited.
func (*ChecksumStore) GetRaw ¶
func (c *ChecksumStore) GetRaw() []byte
func (*ChecksumStore) ReadRaw ¶
func (c *ChecksumStore) ReadRaw(data []byte) error
type Compressor ¶
type Compressor interface { GetFileExtension() string NewReader(r io.Reader) (io.ReadCloser, error) NewWriter(w io.Writer) (io.WriteCloser, error) }
func NewCompressorFromFileName ¶
func NewCompressorFromFileName(name string) (Compressor, error)
func NewCompressorFromId ¶
func NewCompressorFromId(id string) (Compressor, error)
func NewCompressorGzip ¶
func NewCompressorGzip() Compressor
func NewCompressorLzma ¶
func NewCompressorLzma() Compressor
func NewCompressorNone ¶
func NewCompressorNone() Compressor
func NewCompressorZstd ¶
func NewCompressorZstd(level zstd.EncoderLevel) Compressor
type CompressorGzip ¶
type CompressorGzip struct { }
func (*CompressorGzip) GetFileExtension ¶
func (c *CompressorGzip) GetFileExtension() string
func (*CompressorGzip) NewReader ¶
func (c *CompressorGzip) NewReader(r io.Reader) (io.ReadCloser, error)
func (*CompressorGzip) NewWriter ¶
func (c *CompressorGzip) NewWriter(w io.Writer) (io.WriteCloser, error)
type CompressorLzma ¶
type CompressorLzma struct { }
func (*CompressorLzma) GetFileExtension ¶
func (c *CompressorLzma) GetFileExtension() string
func (*CompressorLzma) NewReader ¶
func (c *CompressorLzma) NewReader(r io.Reader) (io.ReadCloser, error)
func (*CompressorLzma) NewWriter ¶
func (c *CompressorLzma) NewWriter(w io.Writer) (io.WriteCloser, error)
type CompressorNone ¶
type CompressorNone struct { }
func (*CompressorNone) GetFileExtension ¶
func (c *CompressorNone) GetFileExtension() string
func (*CompressorNone) NewReader ¶
func (c *CompressorNone) NewReader(r io.Reader) (io.ReadCloser, error)
func (*CompressorNone) NewWriter ¶
func (c *CompressorNone) NewWriter(w io.Writer) (io.WriteCloser, error)
type CompressorZstd ¶
type CompressorZstd struct {
// contains filtered or unexported fields
}
func (*CompressorZstd) GetFileExtension ¶
func (c *CompressorZstd) GetFileExtension() string
func (*CompressorZstd) NewReader ¶
func (c *CompressorZstd) NewReader(r io.Reader) (io.ReadCloser, error)
func (*CompressorZstd) NewWriter ¶
func (c *CompressorZstd) NewWriter(w io.Writer) (io.WriteCloser, error)
type Crypto ¶
type Crypto interface { Sign(message []byte, key interface{}) ([]byte, error) Verify(message, sig []byte, key interface{}) error }
Crypto is an interface each specific signature algorithm must implement in order to be used with PKISigner.
type FileArchiver ¶
func NewTarWriterFile ¶
func NewTarWriterFile(tw *tar.Writer) *FileArchiver
type Files ¶
type Files struct {
FileList []string `json:"files"`
}
Files represents the list of file names that make up the payload for given update.
type HeaderInfo ¶
type HeaderInfo struct { ArtifactName string `json:"artifact_name"` Updates []UpdateType `json:"updates"` CompatibleDevices []string `json:"device_types_compatible"` }
HeaderInfo contains information of number and type of update files archived in Mender metadata archive.
func NewHeaderInfo ¶
func NewHeaderInfo( artifactName string, updates []UpdateType, compatibleDevices []string, ) *HeaderInfo
func (*HeaderInfo) GetArtifactDepends ¶
func (hi *HeaderInfo) GetArtifactDepends() *ArtifactDepends
func (*HeaderInfo) GetArtifactName ¶
func (hi *HeaderInfo) GetArtifactName() string
Satisfy HeaderInfoer interface for the artifact reader.
func (*HeaderInfo) GetArtifactProvides ¶
func (hi *HeaderInfo) GetArtifactProvides() *ArtifactProvides
func (*HeaderInfo) GetCompatibleDevices ¶
func (hi *HeaderInfo) GetCompatibleDevices() []string
Satisfy HeaderInfoer interface for the artifact reader.
func (*HeaderInfo) GetUpdates ¶
func (hi *HeaderInfo) GetUpdates() []UpdateType
Satisfy HeaderInfoer interface for the artifact reader.
func (*HeaderInfo) UnmarshalJSON ¶
func (h *HeaderInfo) UnmarshalJSON(b []byte) error
func (HeaderInfo) Validate ¶
func (hi HeaderInfo) Validate() error
Validate checks if header-info structure is correct.
type HeaderInfoV3 ¶
type HeaderInfoV3 struct { // For historical reasons, "payloads" are often referred to as "updates" // in the code, since this was the old name (and still is, in V2). // This is the reason why the struct field is still called // "Updates". Updates []UpdateType `json:"payloads"` // Has its own json marshaller tags. ArtifactProvides *ArtifactProvides `json:"artifact_provides"` // Has its own json marshaller tags. ArtifactDepends *ArtifactDepends `json:"artifact_depends"` }
func NewHeaderInfoV3 ¶
func NewHeaderInfoV3(updates []UpdateType, artifactProvides *ArtifactProvides, artifactDepends *ArtifactDepends) *HeaderInfoV3
func (*HeaderInfoV3) GetArtifactDepends ¶
func (hi *HeaderInfoV3) GetArtifactDepends() *ArtifactDepends
func (*HeaderInfoV3) GetArtifactName ¶
func (hi *HeaderInfoV3) GetArtifactName() string
Satisfy HeaderInfoer interface for the artifact reader.
func (*HeaderInfoV3) GetArtifactProvides ¶
func (hi *HeaderInfoV3) GetArtifactProvides() *ArtifactProvides
func (*HeaderInfoV3) GetCompatibleDevices ¶
func (hi *HeaderInfoV3) GetCompatibleDevices() []string
Satisfy HeaderInfoer interface for the artifact reader.
func (*HeaderInfoV3) GetUpdates ¶
func (hi *HeaderInfoV3) GetUpdates() []UpdateType
Satisfy HeaderInfoer interface for the artifact reader.
func (*HeaderInfoV3) Validate ¶
func (hi *HeaderInfoV3) Validate() error
Validate validates the correctness of the header version3.
type HeaderInfoer ¶
type HeaderInfoer interface { Write(b []byte) (n int, err error) GetArtifactName() string GetCompatibleDevices() []string GetUpdates() []UpdateType GetArtifactDepends() *ArtifactDepends GetArtifactProvides() *ArtifactProvides }
HeaderInfoer wraps headerInfo version 2 and 3, in order to supply the artifact reader with the information it needs.
type Info ¶
Info contains the information about the format and the version of artifact archive.
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.
type PKCS11Signer ¶
type PKCS11Signer struct {
Key openssl.PrivateKey
}
func NewPKCS11Signer ¶
func NewPKCS11Signer(pkcsKey string) (*PKCS11Signer, error)
func (*PKCS11Signer) Verify ¶
func (s *PKCS11Signer) Verify(message, sig []byte) error
type PKISigner ¶
type PKISigner struct {
// contains filtered or unexported fields
}
PKISigner implements public-key encryption and supports X.509-encodded keys. For now both RSA and 256 bits ECDSA are supported.
func NewPKISigner ¶
func NewPKIVerifier ¶
type SigningMethod ¶
type SigningMethod struct { // Key can be private or public depending if we want to sign or verify message Key interface{} Public []byte Method Crypto }
func GetKeyAndSignMethod ¶
func GetKeyAndSignMethod(keyPEM []byte) (*SigningMethod, error)
func GetKeyAndVerifyMethod ¶
func GetKeyAndVerifyMethod(keyPEM []byte) (*SigningMethod, error)
type StreamArchiver ¶
func NewTarWriterStream ¶
func NewTarWriterStream(w *tar.Writer) *StreamArchiver
type TypeInfo ¶
type TypeInfo struct {
Type string `json:"type"`
}
TypeInfo provides information of type of individual updates archived in artifacts archive.
type TypeInfoDepends ¶
type TypeInfoDepends map[string]interface{}
func NewTypeInfoDepends ¶
func NewTypeInfoDepends(m interface{}) (ti TypeInfoDepends, err error)
func (TypeInfoDepends) Map ¶
func (t TypeInfoDepends) Map() map[string]interface{}
func (*TypeInfoDepends) UnmarshalJSON ¶
func (t *TypeInfoDepends) UnmarshalJSON(b []byte) error
UnmarshalJSON attempts to deserialize the json stream into a 'map[string]interface{}', where each interface value is required to be either a string, or an array of strings
type TypeInfoProvides ¶
func NewTypeInfoProvides ¶
func NewTypeInfoProvides(m interface{}) (ti TypeInfoProvides, err error)
func (TypeInfoProvides) Map ¶
func (t TypeInfoProvides) Map() map[string]string
func (*TypeInfoProvides) UnmarshalJSON ¶
func (t *TypeInfoProvides) UnmarshalJSON(b []byte) error
UnmarshalJSON attempts to deserialize the json stream into a 'map[string]interface{}', where each interface value is required to be either a string, or an array of strings
type TypeInfoV3 ¶
type TypeInfoV3 struct { // Rootfs/Delta (Required). Type *string `json:"type"` ArtifactDepends TypeInfoDepends `json:"artifact_depends,omitempty"` ArtifactProvides TypeInfoProvides `json:"artifact_provides,omitempty"` ClearsArtifactProvides []string `json:"clears_artifact_provides,omitempty"` }
TypeInfoV3 provides information about the type of update contained within the headerstructure.
func (*TypeInfoV3) Validate ¶
func (ti *TypeInfoV3) Validate() error
Validate checks that the required `Type` field is set.
type UpdateType ¶
type UpdateType struct {
Type *string `json:"type"`
}
UpdateType provides information about the type of update. At the moment the only built-in type is "rootfs-image".
type WriteValidator ¶
WriteValidator is the interface that wraps the io.Writer interface and Validate method.