Documentation ¶
Overview ¶
Package updater is an update registry that manages updates and versions.
Index ¶
- Variables
- func GetIdentifierAndVersion(versionedPath string) (identifier, version string, ok bool)
- func GetVersionedPath(identifier, version string) (versionedPath string)
- type File
- type Resource
- func (res *Resource) AddVersion(version string, available, stableRelease, betaRelease bool) error
- func (res *Resource) Blacklist(version string) error
- func (res *Resource) GetFile() *File
- func (res *Resource) Len() int
- func (res *Resource) Less(i, j int) bool
- func (res *Resource) Purge(keep int)
- func (res *Resource) Swap(i, j int)
- type ResourceRegistry
- func (reg *ResourceRegistry) AddResource(identifier, version string, available, stableRelease, betaRelease bool) error
- func (reg *ResourceRegistry) AddResources(versions map[string]string, available, stableRelease, betaRelease bool) error
- func (reg *ResourceRegistry) Cleanup() error
- func (reg *ResourceRegistry) CreateSymlinks(symlinkRoot *utils.DirStructure) error
- func (reg *ResourceRegistry) DownloadUpdates(ctx context.Context) error
- func (reg *ResourceRegistry) Export() map[string]*Resource
- func (reg *ResourceRegistry) GetFile(identifier string) (*File, error)
- func (reg *ResourceRegistry) GetSelectedVersions() (versions map[string]string)
- func (reg *ResourceRegistry) Initialize(storageDir *utils.DirStructure) error
- func (reg *ResourceRegistry) LoadIndexes() error
- func (reg *ResourceRegistry) Purge(keep int)
- func (reg *ResourceRegistry) ScanStorage(root string) error
- func (reg *ResourceRegistry) SelectVersions()
- func (reg *ResourceRegistry) SetBeta(on bool)
- func (reg *ResourceRegistry) SetDevMode(on bool)
- func (reg *ResourceRegistry) StorageDir() *utils.DirStructure
- func (reg *ResourceRegistry) TmpDir() *utils.DirStructure
- func (reg *ResourceRegistry) UpdateIndexes() error
- type ResourceVersion
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("the requested file could not be found") ErrNotAvailableLocally = errors.New("the requested file is not available locally") )
Errors
Functions ¶
func GetIdentifierAndVersion ¶
GetIdentifierAndVersion splits the given file path into its identifier and version.
func GetVersionedPath ¶
GetVersionedPath combines the identifier and version and returns it as a file path.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a file from the update system.
func (*File) Blacklist ¶
Blacklist notifies the update system that this file is somehow broken, and should be ignored from now on, until restarted.
func (*File) Identifier ¶
Identifier returns the identifier of the file.
func (*File) UpgradeAvailable ¶
UpgradeAvailable returns whether an upgrade is available for this file.
func (*File) WaitForAvailableUpgrade ¶
func (file *File) WaitForAvailableUpgrade() <-chan struct{}
WaitForAvailableUpgrade blocks (selectable) until an upgrade for this file is available.
type Resource ¶
type Resource struct { sync.Mutex Identifier string Versions []*ResourceVersion ActiveVersion *ResourceVersion SelectedVersion *ResourceVersion ForceDownload bool // contains filtered or unexported fields }
Resource represents a resource (via an identifier) and multiple file versions.
func (*Resource) AddVersion ¶
AddVersion adds a resource version to a resource.
func (*Resource) Len ¶
Len is the number of elements in the collection. (sort.Interface for Versions)
func (*Resource) Less ¶
Less reports whether the element with index i should sort before the element with index j. (sort.Interface for Versions)
type ResourceRegistry ¶
type ResourceRegistry struct { sync.RWMutex Name string UpdateURLs []string MandatoryUpdates []string Beta bool DevMode bool Online bool // contains filtered or unexported fields }
ResourceRegistry is a registry for managing update resources.
func (*ResourceRegistry) AddResource ¶
func (reg *ResourceRegistry) AddResource(identifier, version string, available, stableRelease, betaRelease bool) error
AddResource adds a resource to the registry. Does _not_ select new version.
func (*ResourceRegistry) AddResources ¶
func (reg *ResourceRegistry) AddResources(versions map[string]string, available, stableRelease, betaRelease bool) error
AddResources adds resources to the registry. Errors are logged, the last one is returned. Despite errors, non-failing resources are still added. Does _not_ select new versions.
func (*ResourceRegistry) Cleanup ¶
func (reg *ResourceRegistry) Cleanup() error
Cleanup removes temporary files.
func (*ResourceRegistry) CreateSymlinks ¶
func (reg *ResourceRegistry) CreateSymlinks(symlinkRoot *utils.DirStructure) error
CreateSymlinks creates a directory structure with unversions symlinks to the given updates list.
func (*ResourceRegistry) DownloadUpdates ¶
func (reg *ResourceRegistry) DownloadUpdates(ctx context.Context) error
DownloadUpdates checks if updates are available and downloads updates of used components.
func (*ResourceRegistry) Export ¶
func (reg *ResourceRegistry) Export() map[string]*Resource
Export exports the list of resources. All resources must be locked when accessed.
func (*ResourceRegistry) GetFile ¶
func (reg *ResourceRegistry) GetFile(identifier string) (*File, error)
GetFile returns the selected (mostly newest) file with the given identifier or an error, if it fails.
func (*ResourceRegistry) GetSelectedVersions ¶
func (reg *ResourceRegistry) GetSelectedVersions() (versions map[string]string)
GetSelectedVersions returns a list of the currently selected versions.
func (*ResourceRegistry) Initialize ¶
func (reg *ResourceRegistry) Initialize(storageDir *utils.DirStructure) error
Initialize initializes a raw registry struct and makes it ready for usage.
func (*ResourceRegistry) LoadIndexes ¶
func (reg *ResourceRegistry) LoadIndexes() error
LoadIndexes loads the current release indexes from disk and will fetch a new version if not available and online.
func (*ResourceRegistry) Purge ¶
func (reg *ResourceRegistry) Purge(keep int)
Purge deletes old updates, retaining a certain amount, specified by the keep parameter. Will at least keep 2 updates per resource.
func (*ResourceRegistry) ScanStorage ¶
func (reg *ResourceRegistry) ScanStorage(root string) error
ScanStorage scans root within the storage dir and adds found resources to the registry. If an error occurred, it is logged and the last error is returned. Everything that was found despite errors is added to the registry anyway. Leave root empty to scan the full storage dir.
func (*ResourceRegistry) SelectVersions ¶
func (reg *ResourceRegistry) SelectVersions()
SelectVersions selects new resource versions depending on the current registry state.
func (*ResourceRegistry) SetBeta ¶
func (reg *ResourceRegistry) SetBeta(on bool)
SetBeta sets the beta flag.
func (*ResourceRegistry) SetDevMode ¶
func (reg *ResourceRegistry) SetDevMode(on bool)
SetDevMode sets the development mode flag.
func (*ResourceRegistry) StorageDir ¶
func (reg *ResourceRegistry) StorageDir() *utils.DirStructure
StorageDir returns the main storage dir of the resource registry.
func (*ResourceRegistry) TmpDir ¶
func (reg *ResourceRegistry) TmpDir() *utils.DirStructure
TmpDir returns the temporary working dir of the resource registry.
func (*ResourceRegistry) UpdateIndexes ¶
func (reg *ResourceRegistry) UpdateIndexes() error
UpdateIndexes downloads the current update indexes.