Documentation ¶
Index ¶
- Constants
- Variables
- func ExtractArchive(dir string) error
- func FindAvailableLocation(parent string) (string, error)
- func ReadLn(fn string) (string, error)
- func SplitArtifacts(r rune) bool
- func WriteLn(fn string, status string) error
- type Artifact
- type Module
- type Progress
- type Storage
- func (st *Storage) ArchiveModule(dir string) error
- func (st *Storage) Close()
- func (st *Storage) DownloadModule(toDir string, module *Module, progress Progress, serverCert string, ...) (err error)
- func (st *Storage) LoadInstalledDeps() ([]*hawkbit.DependencyDescription, error)
- func (st *Storage) LoadSoftwareUpdatables() map[string]*Updatable
- func (st *Storage) MoveInstalledDeps(dir string, metadata map[string]string) error
- type Updatable
- type Validation
Constants ¶
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" )
const ProtocolFile = "FILE"
ProtocolFile represents protocol for artifacts on local file system
Variables ¶
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 ¶
ExtractArchive all artifacts to file system and remove the archive.
func FindAvailableLocation ¶
FindAvailableLocation search for available directory in provided directory.
func SplitArtifacts ¶
SplitArtifacts is a helper function, passed to strings.FieldsFunc, specifying the valid separators between artifacts and install directories.
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:
- checksums#SHA256
- checksums#SHA1
- checksums#SHA256
- checksums#MD5
- 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 ¶
NewStorage for Script-Based SoftwareUpdatable is created.
func (*Storage) ArchiveModule ¶
ArchiveModule to modules directory.
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 ¶
LoadSoftwareUpdatables from unfinished operations.
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.