updater

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package updater provides functionalities to update the binary to the latest version.

Index

Constants

This section is empty.

Variables

View Source
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

func ConfigureDownloader(githubToken string, timeout time.Duration, opts ...func(c *http.Client))

ConfigureDownloader configures the updater.DefaultDownloader.

func IgnoreReleaseVersion

func IgnoreReleaseVersion(version string) bool

IgnoreReleaseVersion checks if the version is dev build so that force update should be skipped.

func SelfUpdate

func SelfUpdate(ctx context.Context, release updater.Release) error

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 Release

type Release = updater.Release

Release is an alias of updater.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.

Jump to

Keyboard shortcuts

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