updater

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAppVersion

func CheckAppVersion(ctx context.Context, params *CheckVersionParams) (string, error)

CheckAppVersion checks if a newer version of an app is available. Any relevant update info will be returned as a string. It accepts a context for cancellation, or will time out after 5 seconds, whatever is sooner.

func CheckAppVersionAsync

func CheckAppVersionAsync(ctx context.Context, params *CheckVersionParams) func() (string, error)

CheckAppVersionAsync calls CheckAppVersion in a go routine. It returns a closure to be run after program logic which will block until a response is returned or provided context is canceled. The response will include the new version available (if any), and any errors that occur.

Types

type AppResponse

type AppResponse struct {
	AppID          string `json:"appId"`
	AppName        string `json:"appName"`
	AppRepoURL     string `json:"appRepoUrl"`
	CurrentVersion string `json:"currentVersion"`
}

AppResponse is the response object for an app version request. It contains information about the most recent version for a given app.

type CheckVersionParams

type CheckVersionParams struct {
	// The ID of the application to check.
	AppID string

	// The version of the app to check for updates.
	// Should be of form vMAJOR[.MINOR[.PATCH[-PRERELEASE][+BUILD]]] (e.g., v1.0.1)
	Version string

	// An optional Lookuper to load envconfig structs. Will default to os environment variables
	// prefixed with toUpper(AppID).
	Lookuper envconfig.Lookuper

	// Optional override for cached file location. Mostly intended for testing.
	// If empty uses default location.
	CacheFileOverride string
}

CheckVersionParams are the parameters for checking for application updates.

type LocalVersionData

type LocalVersionData struct {
	// Last time version information was checked, in UTC epoch seconds.
	LastCheckTimestamp int64 `json:"lastCheckTimestamp"`

	// Currently unused
	AppResponse *AppResponse
}

LocalVersionData defines the json file that caches version lookup data. Future versions may alert users of cached version info with every invocation.

Jump to

Keyboard shortcuts

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