multiwerf

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const LocalChannelMappingFilename = "multiwerf.json"
View Source
const SelfUpdateLockName = "self-update"
View Source
const UpdateLockName = "update"

Variables

View Source
var AvailableChannels = []string{
	"alpha",
	"beta",
	"ea",
	"stable",
	"rock-solid",
}
View Source
var MultiwerfStorageDir string

MultiwerfStorageDir is an effective path to a storage

Functions

func CalculateSHA256

func CalculateSHA256(filePath string) (string, error)

CalculateSHA256 returns SHA256 hash of filePath content

func CheckIsFileWritable

func CheckIsFileWritable(path string) error

func CheckMajorMinor

func CheckMajorMinor(version string) error

CheckMajorMinor return error if string not in form MAJOR.MINOR

func DirExists added in v1.0.6

func DirExists(path string) (bool, error)

DirExists returns true if path is an existing directory

func ExecUpdatedBinary

func ExecUpdatedBinary(path string) error

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

func ExpandPath(path string) (resPath string, err error)

ExpandPath expands tilde prefix and returns an absolute path

func FileExists

func FileExists(dir string, name string) (bool, error)

FileExists returns true if file `name` is existing in `dir`

func GetSelfExecutableInfo

func GetSelfExecutableInfo() (path string, err error)

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

func HighestSemverVersion(versions []string) (string, error)

HighestSemverVersion returns the latest version from availableVersions array

func IsReleaseFilesExist added in v1.0.15

func IsReleaseFilesExist(dir string, files map[string]string) (bool, error)

func LoadHashFile

func LoadHashFile(dir string, fileName string) (hashes map[string]string)

LoadHashFile opens a file and returns hashes map

func LoadHashMap added in v1.0.6

func LoadHashMap(hashesReader io.Reader) (hashes map[string]string)

LoadHashMap returns a map filename -> hash from reader

func PerformSelfUpdate added in v1.0.15

func PerformSelfUpdate(printer output.Printer) (err error)

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

func ReleaseFiles(pkg string, version string, osArch string) map[string]string

ReleaseFiles return a map with release filenames of package pkg for particular osArch and version

func ReleaseProgramFilename added in v1.1.0

func ReleaseProgramFilename(pkg, version, osArch string) string

func ReplaceBinaryFile

func ReplaceBinaryFile(dir string, currentName string, newName string) (err error)

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 SetupStorageDir(printer output.Printer) error

func TildeExpand

func TildeExpand(path string) (string, error)

TildeExpand expands tilde prefix with home directory path

func Update

func Update(group, channel string, withCache bool) (err error)

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

func Use(group, channel string, forceRemoteCheck, asFile bool, shell string) (err error)

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 ValidateGroup added in v1.1.0

func ValidateGroup(group string, printer output.Printer) error

func VerifyReleaseFileHash

func VerifyReleaseFileHash(dir string, hashFile string, targetFile string) (bool, error)

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

func WerfExec added in v1.1.0

func WerfExec(group, channel string, args []string) (err error)

Exec the latest binary version available for the channel locally with passed args

func WerfPath added in v1.1.0

func WerfPath(group string, channel string) (err error)

Print path to the actual version available for the group/channel locally

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 BinaryInfo struct {
	BinaryPath   string
	Version      string
	HashVerified bool
}

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 ChannelMapping interface {
	GetChannelVersion(group, channel string) (string, error)
	Save() error
}

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 Delayable added in v1.0.10

type Delayable interface {
	WithDelay(d time.Duration)
	IsDelayPassed() bool
	TimeRemains() string
	UpdateTimestamp()
}

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

type UpdateDelay struct {
	Filename string
	Delay    time.Duration
}

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)

Jump to

Keyboard shortcuts

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