update

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: GPL-3.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update checks for new application releases. It verifies a release manifest signed by the release workflow and decides whether it offers a newer version for the running platform.

Index

Constants

View Source
const (
	// MaxManifestSize is the largest manifest.json accepted.
	MaxManifestSize = 64 * 1024

	// MaxSignatureSize is the largest manifest.sig accepted.
	MaxSignatureSize = signing.MaxSignatureSize
)

Variables

This section is empty.

Functions

func Platform

func Platform() string

Platform returns the manifest platform name of the running build, or "" when releases are not built for it.

Types

type Asset

type Asset struct {
	Platform string `json:"platform"`
	File     string `json:"file"`
	Size     int64  `json:"size"`
	SHA256   string `json:"sha256"`
	Binary   Binary `json:"binary"`
}

Asset is one platform's release zip.

type Binary

type Binary struct {
	Path   string `json:"path"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

Binary is the application binary inside a release zip.

type Keys

type Keys = signing.Keys

Keys holds the trusted update signing public keys.

func ParseKeys

func ParseKeys(entries []string) (Keys, []error)

ParseKeys parses public keys of the form algorithm:base64. See signing.ParseKeys.

type Manifest

type Manifest struct {
	Schema  int     `json:"schema"`
	App     string  `json:"app"`
	Version string  `json:"version"`
	Assets  []Asset `json:"assets"`
}

Manifest is a release's update manifest.

func (*Manifest) Asset

func (m *Manifest) Asset(platform string) *Asset

Asset returns the asset for a platform, or nil if there is none.

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source is where an application's releases are published: the latest release's manifest and signature file, and the release pages.

func NewSource

func NewSource(manifestURL, signatureURL, releasePageURL string) (*Source, error)

NewSource returns the release source for the given URLs. Each must be an absolute HTTPS URL. In releasePageURL, {version} is replaced by the offered version.

func (*Source) FetchLatest

func (s *Source) FetchLatest() (manifest, sig []byte, err error)

FetchLatest downloads the latest release's manifest and signature file

func (*Source) ReleasePage

func (s *Source) ReleasePage(version string) string

ReleasePage returns the URL of the release page for a version. The version must come from a verified manifest, which limits it to MAJOR.MINOR.PATCH.

type Status

type Status int

Status is the result of checking a manifest.

const (
	// Invalid means the manifest failed verification.
	Invalid Status = iota
	// NoUpdate means the manifest verified but does not offer a newer
	// version for the running platform.
	NoUpdate
	// Available means the manifest offers a newer version for the running
	// platform.
	Available
)

type Target

type Target struct {
	App      string
	Version  Version
	Platform string
	Keys     Keys
}

Target is the running application a manifest is checked against.

func (*Target) Check

func (t *Target) Check(manifest, sig []byte) (Status, *Manifest, error)

Check verifies a manifest and its signature file and reports whether it offers an update. The returned manifest is set only when an update is available. The error is set only for Invalid and gives the reason.

type Version

type Version struct {
	Major, Minor, Patch int
}

Version is a release version.

func ParseVersion

func ParseVersion(s string) (Version, bool)

ParseVersion parses a release version of exactly the form MAJOR.MINOR.PATCH and reports whether it is one. A leading "v", used by release tags, is not part of a version.

func RunningVersion

func RunningVersion(s string) Version

RunningVersion parses the running application's version. A version that is not a release version is treated as 0.0.0, so any release is newer.

func (Version) Less

func (v Version) Less(o Version) bool

Less reports whether v is older than o.

Jump to

Keyboard shortcuts

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