pkg

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalInfo

func SetGlobalInfo(latest PackageInfo)

SetGlobalInfo a function that can modify the singleton PackageInfo

func Upgrade

func Upgrade(latest PackageInfo) (err error)

Upgrade downloads the latest version and overwrites the current version; if the upgrade fails, the binary is rolled back to the version that was already on disk; if the rollback fails, the function will panic

func VersionCheckHook

func VersionCheckHook(disabled bool, upgradeCallback, upgradeNotRequired UpgradeCallback) error

VersionCheckHook prompts user for upgrade and upgrades the package in place if accepted

Types

type PackageInfo

type PackageInfo struct {
	Version           string `json:"version"`
	Environment       string `json:"environment"`
	Hash              string `json:"hash"`
	RemoteVersionURL  string `json:"remote_version_url"`
	LatestDownloadURL string `json:"latest_download_url"`
}

PackageInfo a data container struct intended to be used with -ldflags and injecting package version data

func GlobalInfo

func GlobalInfo() PackageInfo

GlobalInfo returns a singleton of PackageInfo that should have package data injected with -ldflags

func (PackageInfo) CheckVersion

func (current PackageInfo) CheckVersion() (bool, PackageInfo, error)

CheckVersion makes a call to the cdn to check the remote version against the current version If current is less that latest check version returns true

func (*PackageInfo) ComputeHash

func (current *PackageInfo) ComputeHash() error

ComputeHash modifies the current package with the hash of the currently running executable

func (PackageInfo) DownloadLatest

func (current PackageInfo) DownloadLatest() (string, error)

DownloadLatest downloads latest from the domain CDN

func (PackageInfo) ParseVersion

func (current PackageInfo) ParseVersion() (*version.Version, error)

ParseVersion parses a semantic version string

func (PackageInfo) Validate

func (current PackageInfo) Validate() bool

Validate checks if the package has the necessary information to attempt a version check

type UpgradeCallback

type UpgradeCallback func(current PackageInfo, latest PackageInfo) error

UpgradeCallback designates the format for callback functions within the pkg library

Jump to

Keyboard shortcuts

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