Documentation ¶
Overview ¶
Update protocol:
GET hk.heroku.com/hk/linux-amd64.json 200 ok { "Version": "2", "Sha256": "..." // base64 }
then
GET hkpatch.s3.amazonaws.com/hk/1/2/linux-amd64 200 ok [bsdiff data]
or
GET hkdist.s3.amazonaws.com/hk/2/linux-amd64.gz 200 ok [gzipped executable data]
Index ¶
- Variables
- type HTTPRequester
- type Requester
- type UpdateInfo
- type Updater
- func (u *Updater) BackgroundRun(ctx context.Context) error
- func (u *Updater) CanUpdate() error
- func (u *Updater) CheckIsThereNewVersion(ctx context.Context) (*semver.Version, error)
- func (u *Updater) FetchInfo(ctx context.Context) (UpdateInfo, error)
- func (u *Updater) ForegroundRun(ctx context.Context) (bool, error)
- func (u *Updater) Update(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ErrHashMismatch = errors.New("new file hash mismatch after patch")
var ErrNoAvailableUpdates = errors.New("no available updates")
var ErrNotNowHolder = errors.New("")
Functions ¶
This section is empty.
Types ¶
type HTTPRequester ¶
type HTTPRequester struct { }
HTTPRequester is the normal requester that is used and does an HTTP to the url location requested to retrieve the specified data.
func (*HTTPRequester) Fetch ¶
func (httpRequester *HTTPRequester) Fetch(ctx context.Context, url string) (io.ReadCloser, error)
Fetch will return an HTTP request to the specified url and return the body of the result. An error will occur for a non 200 status code.
type Requester ¶
Requester interface allows developers to customize the method in which requests are made to retrieve the version and binary
type UpdateInfo ¶
Updater is the configuration and runtime data for doing an update.
Note that ApiURL, BinURL and DiffURL should have the same value if all files are available at the same location.
Example:
updater := &selfupdate.Updater{ CurrentVersion: version, ApiURL: "http://updates.yourdomain.com/", BinURL: "http://updates.yourdownmain.com/", DiffURL: "http://updates.yourdomain.com/", Dir: "update/", CmdName: "myapp", // app name } if updater != nil { go updater.BackgroundRun() }
type Updater ¶
type Updater struct { CurrentVersion string // Currently running version. ApiURL string // Base URL for API requests (json files). CmdName string // Command name is appended to the ApiURL like http://apiurl/CmdName/. This represents one binary. BinURL string // Base URL for full binary downloads. DiffURL string // Base URL for diff downloads. Dir string // Directory to store selfupdate state. ForceCheck bool // Check for update regardless of cktime timestamp Requester Requester //Optional parameter to override existing http request handler Info UpdateInfo }
func (*Updater) BackgroundRun ¶
BackgroundRun starts the update check and apply cycle.
func (*Updater) CheckIsThereNewVersion ¶
CheckIsThereNewVersion to check if there is an update without pulling the binary
func (*Updater) FetchInfo ¶
func (u *Updater) FetchInfo(ctx context.Context) (UpdateInfo, error)
FetchInfo fetches and provides information about current latest version
func (*Updater) ForegroundRun ¶
ForegroundRun starts the update check and apply cycle, returns updated or not.