Documentation ¶
Overview ¶
Package selfupdate 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 AlwaysCheckForUpdatesSchedule
- type CheckForUpdatesSchedule
- type CurrentExeUpdatableResolver
- type CurrentPlatformResolver
- type FsCacheCheckForUpdateSchedule
- type HTTPRequester
- type PlatformResolver
- type Requester
- type SpecificFileUpdatableResolver
- type SpecificPlatformResolver
- type UpdatableResolver
- type Updater
Constants ¶
This section is empty.
Variables ¶
var ErrHashMismatch = errors.New("new file hash mismatch after patch")
ErrHashMismatch returned whenever the new file's hash is mismatched after patch, indicating patch was unsuccesful.
Functions ¶
This section is empty.
Types ¶
type AlwaysCheckForUpdatesSchedule ¶
type AlwaysCheckForUpdatesSchedule struct {
// contains filtered or unexported fields
}
AlwaysCheckForUpdatesSchedule will always want to update
func NewAlwaysCheckForUpdatesSchedule ¶
func NewAlwaysCheckForUpdatesSchedule(secondsToWaitBetweenChecking int) AlwaysCheckForUpdatesSchedule
NewAlwaysCheckForUpdatesSchedule that will want to check if
func (AlwaysCheckForUpdatesSchedule) NextTimeToCheck ¶
func (a AlwaysCheckForUpdatesSchedule) NextTimeToCheck() (time.Time, error)
NextTimeToCheck tells us the next time we should check if there are any updates available
func (AlwaysCheckForUpdatesSchedule) ShouldCheckForUpdate ¶
func (a AlwaysCheckForUpdatesSchedule) ShouldCheckForUpdate() (bool, error)
ShouldCheckForUpdate will always return true
type CheckForUpdatesSchedule ¶
type CheckForUpdatesSchedule interface { ShouldCheckForUpdate(currentTime time.Time) (bool, error) UpdatesChecked(timeUpdatesWhereChecked time.Time) error }
CheckForUpdatesSchedule denotes when it's appropriate to check for an update
func DefaultCheckForUpdateSchedule ¶
func DefaultCheckForUpdateSchedule() CheckForUpdatesSchedule
DefaultCheckForUpdateSchedule is a filesystem cache that checks for updates every 24 hours
type CurrentExeUpdatableResolver ¶
type CurrentExeUpdatableResolver struct { }
CurrentExeUpdatableResolver resolves the thing to be updated as the current executable running this program
func (CurrentExeUpdatableResolver) Resolve ¶
func (c CurrentExeUpdatableResolver) Resolve() (string, error)
Resolve attempts to find the current executable running this program
type CurrentPlatformResolver ¶
type CurrentPlatformResolver struct { }
CurrentPlatformResolver will create a key that corresponds to the current OS and architecture this program is running on
func (CurrentPlatformResolver) Resolve ¶
func (c CurrentPlatformResolver) Resolve() (string, error)
Resolve returns the current architecture and operating system
type FsCacheCheckForUpdateSchedule ¶
type FsCacheCheckForUpdateSchedule struct {
// contains filtered or unexported fields
}
FsCacheCheckForUpdateSchedule uses the filesystem to keep up with when the last time we checked for updated where.
func NewFsCacheCheckForUpdateSchedule ¶
func NewFsCacheCheckForUpdateSchedule(cacheDir, filename string, durationBetweenChecks time.Duration) FsCacheCheckForUpdateSchedule
NewFsCacheCheckForUpdateSchedule creates a new schedule that stores it's contents on a file system
func (FsCacheCheckForUpdateSchedule) ShouldCheckForUpdate ¶
func (fs FsCacheCheckForUpdateSchedule) ShouldCheckForUpdate(currentTime time.Time) (bool, error)
ShouldCheckForUpdate determines whether or not we should check for updates.
func (FsCacheCheckForUpdateSchedule) UpdatesChecked ¶
func (fs FsCacheCheckForUpdateSchedule) UpdatesChecked(timeUpdatesWhereChecked time.Time) error
UpdatesChecked marks that updates have been checked.
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(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 PlatformResolver ¶
PlatformResolver determines the platform that that the file exists for that needs to be updated.
type Requester ¶
type Requester interface {
Fetch(url string) (io.ReadCloser, error)
}
Requester interface allows developers to customize the method in which requests are made to retrieve the version and binary
type SpecificFileUpdatableResolver ¶
type SpecificFileUpdatableResolver struct {
// contains filtered or unexported fields
}
SpecificFileUpdatableResolver resolves the thing to be updated with a path to a specific file on disk.
func NewSpecificFileUpdatableResolver ¶
func NewSpecificFileUpdatableResolver(path string) SpecificFileUpdatableResolver
NewSpecificFileUpdatableResolver returns a resolver that resolves to the specific file path passed in.
func (SpecificFileUpdatableResolver) Resolve ¶
func (c SpecificFileUpdatableResolver) Resolve() (string, error)
Resolve attempts to find the current executable running this program
type SpecificPlatformResolver ¶
type SpecificPlatformResolver struct {
// contains filtered or unexported fields
}
SpecificPlatformResolver will create a key that based on the operating system and architecture passed in.
func NewSpecificPlatformResolver ¶
func NewSpecificPlatformResolver(os, arch string) SpecificPlatformResolver
func (SpecificPlatformResolver) Resolve ¶
func (c SpecificPlatformResolver) Resolve() (string, error)
Resolve returns the architecture and operating system used to build this resolver
type UpdatableResolver ¶
UpdatableResolver finds the thing that needs to be updated.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
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:
```golang updater := selfupdate.NewUpdater(version, "http://updates.yourdomain.com/", "myapp") updater.Run() ```
func NewUpdater ¶
NewUpdater creates a new updater with defaults that we're updating this executable and it's going to be for the current OS and Architecture
func (*Updater) Run ¶
Run attempts to grab the latest version information and then applies the new patch if their is an update. If an update did occur, then we return true. If we did not update (already up to date) then we return false.
func (Updater) SetPlatformResolver ¶
func (u Updater) SetPlatformResolver(resolver PlatformResolver) Updater
SetPlatformResolver sets what we use to determine what platform the file we're trying to update is for
NOTICE: This does not change the current updater, but makes a new one with the resolver property changed
func (Updater) SetRequester ¶
SetRequester sets what we use to make requests and get binaries. By default uses http. Can replace this with your own to add things like middleware.
NOTICE: This does not change the current updater, but makes a new one with the requester property changed
func (Updater) SetUpdatableResolver ¶
func (u Updater) SetUpdatableResolver(resolver UpdatableResolver) Updater
SetUpdatableResolver sets what we use to determine which file needs to get updated.
NOTICE: This does not change the current updater, but makes a new one with the resolver property changed
func (Updater) UpdateAvailable ¶
UpdateAvailable fetches info from the server specificed and and checks if what the version specified on the server matches what this program's version is.