Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateSHA256(filePath string) (string, error)
- func CheckIsFileWritable(path string) error
- func CheckMajorMinor(version string) error
- func DirExists(path string) (bool, 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 HighestSemverVersion(versions []string) (string, error)
- func IsReleaseFilesExist(dir string, files map[string]string) (bool, error)
- func LoadHashFile(dir string, fileName string) (hashes map[string]string)
- func LoadHashMap(hashesReader io.Reader) (hashes map[string]string)
- func PerformSelfUpdate(printer output.Printer) (err error)
- func PrintActionMessage(msg ActionMessage, printer output.Printer)
- func PrintActionMessages(messages chan ActionMessage, printer output.Printer) error
- func ReleaseFiles(pkg string, version string, osArch string) map[string]string
- func ReleaseProgramFilename(pkg, version, osArch string) string
- func ReplaceBinaryFile(dir string, currentName string, newName string) (err error)
- func SelfUpdate(messages chan ActionMessage) string
- func SetupStorageDir(printer output.Printer) error
- func TildeExpand(path string) (string, error)
- func Update(group, channel string, withCache bool) (err error)
- func Use(group, channel string, forceRemoteCheck, asFile bool, shell string) (err error)
- func ValidateGroup(group string, printer output.Printer) error
- func VerifyReleaseFileHash(dir string, hashFile string, targetFile string) (bool, error)
- func VerifyReleaseFileHashFromHashes(dir string, hashes map[string]string, targetFile string) (bool, error)
- func WerfExec(group, channel string, args []string) (err error)
- func WerfPath(group string, channel string) (err error)
- type ActionMessage
- type BinaryInfo
- type BinaryUpdater
- type ChannelMapping
- type ChannelMappingBase
- type ChannelMappingLocal
- type ChannelMappingRemote
- type Delayable
- type MainBinaryUpdater
- type UpdateDelay
Constants ¶
const LocalChannelMappingFilename = "multiwerf.json"
const SelfUpdateLockName = "self-update"
const UpdateLockName = "update"
Variables ¶
var AvailableChannels = []string{
"alpha",
"beta",
"ea",
"stable",
"rock-solid",
}
var MultiwerfStorageDir string
MultiwerfStorageDir is an effective path to a storage
Functions ¶
func CalculateSHA256 ¶
CalculateSHA256 returns SHA256 hash of filePath content
func CheckIsFileWritable ¶
func CheckMajorMinor ¶
CheckMajorMinor return error if string not in form MAJOR.MINOR
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 HighestSemverVersion ¶ added in v1.1.0
HighestSemverVersion returns the latest version from availableVersions array
func IsReleaseFilesExist ¶ added in v1.0.15
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 PerformSelfUpdate ¶ added in v1.0.15
update multiwerf binary (self-update)
func PrintActionMessage ¶ added in v1.0.15
func PrintActionMessage(msg ActionMessage, printer output.Printer)
func PrintActionMessages ¶ added in v1.0.15
func PrintActionMessages(messages chan ActionMessage, printer output.Printer) error
PrintActionMessages handle ActionMessage events and print messages with printer object
func ReleaseFiles ¶
ReleaseFiles return a map with release filenames of package pkg for particular osArch and version
func ReleaseProgramFilename ¶ added in v1.1.0
func ReplaceBinaryFile ¶
func SelfUpdate ¶
func SelfUpdate(messages chan ActionMessage) string
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 SetupStorageDir ¶ added in v1.1.0
func TildeExpand ¶
TildeExpand expands tilde prefix with home directory path
func Update ¶
Update checks for the actual version for group/channel and downloads it to StorageDir
Arguments:
- group - a major.minor version to update - channel - a string with channel name
This command is fully locked: - if the lock is present then command exits with special message - if the lock is acquired then self-update and update perform as usual
func Use ¶
Use prints a shell script with alias to the actual binary version for the group/channel TODO make script more responsive: print messages immediately
func VerifyReleaseFileHash ¶
VerifyReleaseFileHash verify targetFile in dir accroding to hashFile in dir
There are three states: - err != nil if something is missing false, nil if files are exists, we got hash for file and hashes is not matched true, nil is hashes is matched
func VerifyReleaseFileHashFromHashes ¶ added in v1.0.6
func VerifyReleaseFileHashFromHashes(dir string, hashes map[string]string, targetFile string) (bool, error)
VerifyReleaseFileHashFromHashes verifies targetFile hash with matched hash from hashes map
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 BinaryInfo ¶
type BinaryUpdater ¶ added in v1.0.6
type BinaryUpdater interface {
// UpdateChannelVersion downloads the werf binary according to the remote or local channel mapping
//
// Get the actual werf version for group/channel from the mapping
// Check version locally and remotely
// * if local version exists and it is valid then use it
// * otherwise, download and verify the actual binary from bintray
// Override local channel mapping
UpdateChannelVersion(group, channel string) (binInfo *BinaryInfo)
}
func NewBinaryUpdater ¶ added in v1.0.6
func NewBinaryUpdater(messages chan ActionMessage, remoteEnabled bool) BinaryUpdater
type ChannelMapping ¶ added in v1.1.0
type ChannelMappingBase ¶ added in v1.1.0
type ChannelMappingBase struct {
Multiwerf []struct {
Group string `json:"group"`
Channels []struct {
Name string `json:"name"`
Version string `json:"version"`
} `json:"channels"`
} `json:"multiwerf"`
}
func (*ChannelMappingBase) GetChannelVersion ¶ added in v1.1.0
func (c *ChannelMappingBase) GetChannelVersion(group, channel string) (string, error)
func (*ChannelMappingBase) Save ¶ added in v1.1.0
func (c *ChannelMappingBase) Save() error
type ChannelMappingLocal ¶ added in v1.1.0
type ChannelMappingLocal struct {
ChannelMappingBase
}
type ChannelMappingRemote ¶ added in v1.1.0
type ChannelMappingRemote struct {
ChannelMappingBase
}
func (*ChannelMappingRemote) Save ¶ added in v1.1.0
func (c *ChannelMappingRemote) Save() error
type MainBinaryUpdater ¶ added in v1.0.6
type MainBinaryUpdater struct {
BintrayClient bintray.BintrayClient
Messages chan ActionMessage
RemoteEnabled bool
ChannelMapping ChannelMapping
}
func (*MainBinaryUpdater) InitChannelMapping ¶ added in v1.1.0
func (u *MainBinaryUpdater) InitChannelMapping()
func (*MainBinaryUpdater) UpdateChannelVersion ¶ added in v1.1.0
func (u *MainBinaryUpdater) UpdateChannelVersion(group string, channel string) (binInfo *BinaryInfo)
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) TimeRemains ¶ added in v1.0.15
func (u *UpdateDelay) TimeRemains() string
TimeRemains returns a string representation of time until delay is passed. Empty string is returned if delay is passed
func (*UpdateDelay) UpdateTimestamp ¶ added in v1.0.10
func (u *UpdateDelay) UpdateTimestamp()
UpdateTimestamp sets delay timestamp as now() be recreating a delay file
func (*UpdateDelay) WithDelay ¶ added in v1.0.15
func (u *UpdateDelay) WithDelay(d time.Duration)