Documentation ¶
Overview ¶
Package updater provides functionalities to update the binary to the latest version.
Index ¶
- Variables
- func CheckLatestRelease(ctx context.Context, l ReleaseLocator, currentVersion string, log ctxd.Logger) error
- func ConfigureDownloader(githubToken string, timeout time.Duration, opts ...func(c *http.Client))
- func IgnoreReleaseVersion(version string) bool
- func SelfUpdate(ctx context.Context, release updater.Release) error
- type DefaultReleaseLocator
- type MissingGitHubTokenLocator
- type Release
- type ReleaseLocator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoGithubToken indicates that no GitHub token was provided. ErrNoGithubToken = errors.New("no github token provided") // ErrReleaseAssetNotFound indicates that release asset was not found for the current platform. ErrReleaseAssetNotFound = errors.New("release asset not found for the current platform") // ErrReleaseNoAssets indicates that release has no assets. ErrReleaseNoAssets = errors.New("release has no assets") // ErrReleaseNoTag indicates that release has no name. ErrReleaseNoTag = errors.New("release has no tag") // ErrReleaseNotLatest indicates that release is not the latest. ErrReleaseNotLatest = errors.New("outdated version") )
Functions ¶
func CheckLatestRelease ¶
func CheckLatestRelease(ctx context.Context, l ReleaseLocator, currentVersion string, log ctxd.Logger) error
CheckLatestRelease checks if the running application has the latest available version.
func ConfigureDownloader ¶
ConfigureDownloader configures the updater.DefaultDownloader.
func IgnoreReleaseVersion ¶
IgnoreReleaseVersion checks if the version is dev build so that force update should be skipped.
func SelfUpdate ¶
SelfUpdate update the current executable to the release.
Types ¶
type DefaultReleaseLocator ¶
type DefaultReleaseLocator struct {
// contains filtered or unexported fields
}
DefaultReleaseLocator locates releases for a single app.
func (DefaultReleaseLocator) FindRelease ¶
func (l DefaultReleaseLocator) FindRelease(ctx context.Context, version string) (updater.Release, error)
FindRelease returns the release by version.
func (DefaultReleaseLocator) LatestRelease ¶
func (l DefaultReleaseLocator) LatestRelease(ctx context.Context) (updater.Release, error)
LatestRelease returns the latest release.
type MissingGitHubTokenLocator ¶
type MissingGitHubTokenLocator struct{}
MissingGitHubTokenLocator locates releases without GitHub token.
func (MissingGitHubTokenLocator) FindRelease ¶
func (MissingGitHubTokenLocator) FindRelease(context.Context, string) (updater.Release, error)
FindRelease returns the release by version.
func (MissingGitHubTokenLocator) LatestRelease ¶
func (MissingGitHubTokenLocator) LatestRelease(context.Context) (updater.Release, error)
LatestRelease returns the latest release.
type ReleaseLocator ¶
type ReleaseLocator interface { LatestRelease(ctx context.Context) (updater.Release, error) FindRelease(ctx context.Context, version string) (updater.Release, error) }
ReleaseLocator locates releases.
func NewReleaseLocator ¶
func NewReleaseLocator(githubToken string, timeout time.Duration) ReleaseLocator
NewReleaseLocator creates a new ReleaseLocator.