storage

package
v0.1.0-M4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0, EPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InternalStatusName represents the name of the internal status file.
	InternalStatusName = "internal-status"
	// SoftwareUpdatableName represents the name of the software updatable file.
	SoftwareUpdatableName = "updatable.json"
)
View Source
const ProtocolFile = "FILE"

ProtocolFile represents protocol for artifacts on local file system

Variables

View Source
var (
	// ErrCancel represents cancel operation error.
	ErrCancel = errors.New("cancel operation")
	// ErrFileSizeExceeded represents file size exceeded error.
	ErrFileSizeExceeded = errors.New("file size exceeded")
)

Functions

func ExtractArchive

func ExtractArchive(dir string) error

ExtractArchive all artifacts to file system and remove the archive.

func FindAvailableLocation

func FindAvailableLocation(parent string) (string, error)

FindAvailableLocation search for available directory in provided directory.

func ReadLn

func ReadLn(fn string) (string, error)

ReadLn reads reads first line from a file.

func SplitArtifacts

func SplitArtifacts(r rune) bool

SplitArtifacts is a helper function, passed to strings.FieldsFunc, specifying the valid separators between artifacts and install directories.

func WriteLn

func WriteLn(fn string, status string) error

WriteLn writes single line to a file.

Types

type Artifact

type Artifact struct {
	FileName  string `json:"fileName"`
	Size      int    `json:"size"`
	HashType  string `json:"hashType"`
	HashValue string `json:"hashValue"`
	Link      string `json:"link"`
	Local     bool   `json:"local"`
	Copy      bool   `json:"copy"`
}

Artifact represents a SoftwareArtifactAction where checksums are simplified to hashType and hashValue. Hash priority is as follow:

  1. checksums#SHA256
  2. checksums#SHA1
  3. checksums#SHA256
  4. checksums#MD5
  5. First downloadable download#links#md5url

Links are simplified to simple list with download URIs without any links for MD5 hashes.

type Module

type Module struct {
	Name      string            `json:"name"`
	Version   string            `json:"version"`
	Artifacts []*Artifact       `json:"artifacts,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty"`
}

Module represents a SoftwareModuleAction.

type Progress

type Progress func(percent int)

Progress represents a callback handler that is called on written file chunk.

type Storage

type Storage struct {
	// DownloadPath represents the download directory location.
	DownloadPath string
	// InstalledDepsPath represents the installed dependencies directory location.
	InstalledDepsPath string
	// ModulesPath represents the downloaded modules directory location.
	ModulesPath string
	// contains filtered or unexported fields
}

A Storage for Script-Based SoftwareUpdatable.

func NewStorage

func NewStorage(location string) (*Storage, error)

NewStorage for Script-Based SoftwareUpdatable is created.

func (*Storage) ArchiveModule

func (st *Storage) ArchiveModule(dir string) error

ArchiveModule to modules directory.

func (*Storage) Close

func (st *Storage) Close()

Close ongoing storage operations.

func (*Storage) DownloadModule

func (st *Storage) DownloadModule(toDir string, module *Module, progress Progress, serverCert string,
	retryCount int, retryInterval time.Duration, validation Validation) (err error)

DownloadModule artifacts to local storage.

func (*Storage) LoadInstalledDeps

func (st *Storage) LoadInstalledDeps() ([]*hawkbit.DependencyDescription, error)

LoadInstalledDeps from file system.

func (*Storage) LoadSoftwareUpdatables

func (st *Storage) LoadSoftwareUpdatables() map[string]*Updatable

LoadSoftwareUpdatables from unfinished operations.

func (*Storage) MoveInstalledDeps

func (st *Storage) MoveInstalledDeps(dir string, metadata map[string]string) error

MoveInstalledDeps to local storage.

type Updatable

type Updatable struct {
	Operation     string    `json:"operation"`
	CorrelationID string    `json:"correlationId"`
	Modules       []*Module `json:"softwareModules,omitempty"`
}

A Updatable represents a simplified SoftwareUpdateAction.

func SaveSoftwareUpdatable

func SaveSoftwareUpdatable(operation string, cid string, to string,
	modules []*hawkbit.SoftwareModuleAction) (*Updatable, error)

SaveSoftwareUpdatable as JSON file to file system.

type Validation

type Validation func() error

Validation represents a callback handler, that validates a module's artifacts, called prior to download.

Jump to

Keyboard shortcuts

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