Documentation
¶
Index ¶
- Variables
- func AvailableReleases(version string, channel string, outputFormat string) (err error)
- func CalculateSHA256(filePath string) (string, error)
- func CheckIsFileWritable(path string) error
- func CheckMajorMinor(version string) error
- func ChooseLatestVersion(version string, channel string, availableVersions []string, ...) (string, error)
- func ChooseLatestVersionSimple(availableVersions []string) (string, error)
- func DirExists(path string) (bool, error)
- func DoSelfUpdate(messages chan ActionMessage) string
- func DownloadVersion(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (err error)
- func ExecUpdatedBinary(path string) error
- func ExpandPath(path string) (resPath string, err error)
- func FileExists(dir string, name string) (bool, error)
- func GetSelfExecutableInfo() (path string, err error)
- func LoadHashFile(dir string, fileName string) (hashes map[string]string)
- func LoadHashMap(hashesReader io.Reader) (hashes map[string]string)
- func PickLatestVersions(version string, versions []string, top int) []string
- func PrintMessages(messages chan ActionMessage, printer output.Printer) error
- func ReleaseFiles(pkg string, version string, osArch string) map[string]string
- func RemoteLatestChannelsReleases(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (releases map[string]string, err error)
- func ReplaceBinaryFile(dir string, currentName string, newName string) (err error)
- func SelfUpdate(messages chan ActionMessage)
- func TildeExpand(path string) (string, error)
- func Update(version string, channel string, args []string) (err error)
- func Use(version string, channel string, forceRemoteCheck bool, args []string) (err error)
- func VerifyReleaseFileHash(dir string, hashFile string, targetFile string) (bool, error)
- func VerifyReleaseFileHashFromHashes(dir string, hashes map[string]string, targetFile string) (bool, error)
- type ActionMessage
- type AllChannelsReleasesInfo
- type AvailableReleasesInformer
- type BinaryInfo
- func GetBinaryInfo(version string, messages chan ActionMessage) (binInfo BinaryInfo, err error)
- func LocalLatestBinaryInfo(version string, channel string, messages chan ActionMessage) (binInfo BinaryInfo, err error)
- func RemoteLatestBinaryInfo(version string, channel string, messages chan ActionMessage, ...) (binInfo BinaryInfo, err error)
- type BinaryUpdater
- type Delayable
- type MainAvailableReleasesInformer
- func (m *MainAvailableReleasesInformer) GetAllChannelsReleases(version string) (info AllChannelsReleasesInfo, err error)
- func (m *MainAvailableReleasesInformer) GetMajorMinorReleases() ([]string, error)
- func (m *MainAvailableReleasesInformer) GetRelease(version string, channel string) (string, error)
- type MainBinaryUpdater
- func (u *MainBinaryUpdater) DownloadLatest(version string, channel string) (binInfo BinaryInfo)
- func (u *MainBinaryUpdater) GetLatestBinaryInfo(version string, channel string) (binInfo BinaryInfo)
- func (u *MainBinaryUpdater) SetRemoteDelayed(delayed bool)
- func (u *MainBinaryUpdater) SetRemoteEnabled(enabled bool)
- type SemverWithChannels
- type UpdateDelay
Constants ¶
This section is empty.
Variables ¶
var AvailableChannels = []string{
"alpha",
"beta",
"rc",
"ea",
"stable",
}
var MultiwerfStorageDir string
MultiwerfStorageDir is an effective path to a storage
Functions ¶
func AvailableReleases ¶ added in v1.0.11
func CalculateSHA256 ¶
CalculateSHA256 returns SHA256 hash of filePath content
func CheckIsFileWritable ¶
func CheckMajorMinor ¶
CheckMajorMinor return error if string not in form MAJOR.MINOR
func ChooseLatestVersion ¶
func ChooseLatestVersion(version string, channel string, availableVersions []string, availableChannels []string) (string, error)
ChooseLatestVersion returns a latest version from availableVersions that suits version and channel constrain.
version is a constrain on MAJOR and MINOR parts
channel is a constrain on Prerelease part
availableChannels is an array of prioritized Prerelease variants
func ChooseLatestVersionSimple ¶
ChooseLatestVersionSimple returns a latest version from availableVersions array
func DoSelfUpdate ¶ added in v1.0.6
func DoSelfUpdate(messages chan ActionMessage) string
func DownloadVersion ¶ added in v1.0.6
func DownloadVersion(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (err error)
func ExecUpdatedBinary ¶
ExecUpdatedBinary replaces current process with process from path binary --self-update=no flag is added to arguments to prevent an infinity loop.
func ExpandPath ¶ added in v1.0.8
ExpandPath expands tilde prefix and returns an absolute path
func FileExists ¶
FileExists returns true if file `name` is existing in `dir`
func GetSelfExecutableInfo ¶
GetSelfExecutableInfo return path of an executable file of current process. If file is not owned by user of the process and has no 0x400 bit — return error
func LoadHashFile ¶
LoadHashFile opens a file and returns hashes map
func LoadHashMap ¶ added in v1.0.6
LoadHashMap returns a map filename -> hash from reader
func PickLatestVersions ¶ added in v1.0.10
func PrintMessages ¶ added in v1.0.6
func PrintMessages(messages chan ActionMessage, printer output.Printer) error
PrintMessages handle ActionMessage events and print messages to the screen
func ReleaseFiles ¶
ReleaseFiles return a map with release filenames of package pkg for particular osArch and version
func RemoteLatestChannelsReleases ¶ added in v1.0.11
func RemoteLatestChannelsReleases(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (releases map[string]string, err error)
RemoteLatestChannelsReleases searches for a latest available version in bintray for each channel
func ReplaceBinaryFile ¶
func SelfUpdate ¶
func SelfUpdate(messages chan ActionMessage)
SelfUpdate checks for new version of multiwerf, download it and execute as a new process. Note: multiwerf has no option to exit on self-update errors.
func TildeExpand ¶
TildeExpand expands tilde prefix into HOME directory
func Use ¶
Use prints a shell script with alias to the latest binary version available for the channel
func VerifyReleaseFileHash ¶
VerifyReleaseFileHash verify targetFile in dir accroding to hashFile in dir TODO transform to VerifyFileHash — return 4 states: no hash file, no target file, not match, match
Types ¶
type ActionMessage ¶
type ActionMessage struct {
// contains filtered or unexported fields
}
ActionMessage is used to send messages from go routines started in use and update commands
type AllChannelsReleasesInfo ¶ added in v1.0.11
type AvailableReleasesInformer ¶ added in v1.0.11
type AvailableReleasesInformer interface {
// GetReleases retrieves information about available releases.
GetMajorMinorReleases() ([]string, error)
// GetllChannelsReleases retrieves infrmation about all channels for MAJOR.MINOR version
GetAllChannelsReleases(version string) (AllChannelsReleasesInfo, error)
// GetRelease returns exact versoin for MAJOR.MINOR and channel as use or update command will do
GetRelease(version string, channel string) (string, error)
}
func NewAvailableReleasesInformer ¶ added in v1.0.11
func NewAvailableReleasesInformer(messages chan ActionMessage) AvailableReleasesInformer
type BinaryInfo ¶
type BinaryInfo struct {
BinaryPath string
Version string
HashVerified bool
AvailableVersions []string
}
func GetBinaryInfo ¶ added in v1.0.6
func GetBinaryInfo(version string, messages chan ActionMessage) (binInfo BinaryInfo, err error)
GetBinaryInfo return BinaryInfo object for binary with exact version if it is stored in MultiwerfStorageDir. Empty object is returned if no binary found. Hash of binary is verified with SHA256SUMS files.
func LocalLatestBinaryInfo ¶ added in v1.0.6
func LocalLatestBinaryInfo(version string, channel string, messages chan ActionMessage) (binInfo BinaryInfo, err error)
LocalLatestBinaryInfo return BinaryInfo for latest localy available version
1. find version dirs in ~/.multiwerf 2. find latest version for channel and verify a hash for that binary
func RemoteLatestBinaryInfo ¶ added in v1.0.10
func RemoteLatestBinaryInfo(version string, channel string, messages chan ActionMessage, btClient bintray.BintrayClient) (binInfo BinaryInfo, err error)
RemoteLatestBinaryInfo searches for a latest available version in bintray
type BinaryUpdater ¶ added in v1.0.6
type BinaryUpdater interface {
// this method is intended to update a binary from remote source
// check remote latest → get local latest → if local need update → download and verify a hash
// ↑no remote — error/exit
// ↑no local — no error
// ↑ error if download failed or hash not verified
DownloadLatest(version string, channel string) (binInfo BinaryInfo)
// this method return BinaryInfo instance
// multiwerf exit with error if no binary found remote or local
// check remote versions — check local version — if local need update — download and verify a hash
GetLatestBinaryInfo(version string, channel string) (binInfo BinaryInfo)
//
SetRemoteEnabled(enabled bool)
SetRemoteDelayed(delayed bool)
}
func NewBinaryUpdater ¶ added in v1.0.6
func NewBinaryUpdater(messages chan ActionMessage) BinaryUpdater
type MainAvailableReleasesInformer ¶ added in v1.0.11
type MainAvailableReleasesInformer struct {
BintrayClient bintray.BintrayClient
Messages chan ActionMessage
}
func (*MainAvailableReleasesInformer) GetAllChannelsReleases ¶ added in v1.0.11
func (m *MainAvailableReleasesInformer) GetAllChannelsReleases(version string) (info AllChannelsReleasesInfo, err error)
TODO
func (*MainAvailableReleasesInformer) GetMajorMinorReleases ¶ added in v1.0.11
func (m *MainAvailableReleasesInformer) GetMajorMinorReleases() ([]string, error)
TODO
func (*MainAvailableReleasesInformer) GetRelease ¶ added in v1.0.11
func (m *MainAvailableReleasesInformer) GetRelease(version string, channel string) (string, error)
type MainBinaryUpdater ¶ added in v1.0.6
type MainBinaryUpdater struct {
BintrayClient bintray.BintrayClient
Messages chan ActionMessage
RemoteEnabled bool
RemoteDelayed bool
}
func (*MainBinaryUpdater) DownloadLatest ¶ added in v1.0.6
func (u *MainBinaryUpdater) DownloadLatest(version string, channel string) (binInfo BinaryInfo)
DownloadLatest check for new latest version in bintray. Exit with error on connection problems or if no versions found for version/channel 1. Check for new version → print version 2. Check hashes existed binaries → print 'version stays' 3. Download and check if no binaries are existed — print 'updated to'
func (*MainBinaryUpdater) GetLatestBinaryInfo ¶ added in v1.0.6
func (u *MainBinaryUpdater) GetLatestBinaryInfo(version string, channel string) (binInfo BinaryInfo)
GetLatestBinaryInfo return BinaryInfo object for latest binary with version/channel. Checks for local versions and remote versions. If no remote version is available — use local version.
func (*MainBinaryUpdater) SetRemoteDelayed ¶ added in v1.0.11
func (u *MainBinaryUpdater) SetRemoteDelayed(delayed bool)
func (*MainBinaryUpdater) SetRemoteEnabled ¶ added in v1.0.11
func (u *MainBinaryUpdater) SetRemoteEnabled(enabled bool)
type SemverWithChannels ¶ added in v1.0.8
SemverWithChannels is a collection of Version instances and implements the sort interface. See the sort package for more details. https://golang.org/pkg/sort/
func (SemverWithChannels) Len ¶ added in v1.0.8
func (c SemverWithChannels) Len() int
Len returns the length of a collection. The number of Version instances on the slice.
func (SemverWithChannels) Less ¶ added in v1.0.8
func (c SemverWithChannels) Less(i, j int) bool
Less is needed for the sort interface to compare two Version objects on the slice. If checks if one is less than the other.
func (SemverWithChannels) Swap ¶ added in v1.0.8
func (c SemverWithChannels) Swap(i, j int)
Swap is needed for the sort interface to replace the Version objects at two different positions in the slice.
type UpdateDelay ¶ added in v1.0.10
func (*UpdateDelay) IsDelayPassed ¶ added in v1.0.10
func (u *UpdateDelay) IsDelayPassed() bool
IsDelayPassed returns true if delay has passed since last UpdateTimestamp
func (*UpdateDelay) SetDelay ¶ added in v1.0.10
func (u *UpdateDelay) SetDelay(d time.Duration)
func (*UpdateDelay) UpdateTimestamp ¶ added in v1.0.10
func (u *UpdateDelay) UpdateTimestamp()
UpdateTimestamp sets delay timestamp as now()