selfupdate

package
v0.8.77 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0, AGPL-3.0-or-later, Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAssetNotFound    warpnet.WarpError = "release asset not found"
	ErrChecksumNotFound warpnet.WarpError = "checksum not found"
	ErrChecksumMismatch warpnet.WarpError = "checksum mismatch"
	ErrBinaryNotFound   warpnet.WarpError = "binary not found in archive"
	ErrUnexpectedStatus warpnet.WarpError = "unexpected response status"
	ErrTooLarge         warpnet.WarpError = "downloaded data too large"
	ErrNoReleaseTag     warpnet.WarpError = "release has no tag"
	ErrRestartFailed    warpnet.WarpError = "fail restarting"
	ErrNoPendingUpdate  warpnet.WarpError = "no release is waiting for an answer"
	ErrReleaseUnsigned  warpnet.WarpError = "release carries no signature"
	ErrMalformedKey     warpnet.WarpError = "malformed release signing key"
	ErrNoReleaseSource  warpnet.WarpError = "no forge to read releases from"
	ErrReadOnlyInstall  warpnet.WarpError = "the binary cannot be replaced where it is installed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact added in v0.8.77

type Artifact struct {
	AssetName     string // archive attached to the release
	ChecksumName  string // SHA-256 listing of AssetName
	SignatureName string // ed25519 signature of ChecksumName
	BinaryName    string // executable inside the archive
}

Artifact points at the release asset carrying a replacement for the running binary. A zero Artifact means the running platform has no published asset and self-update stays off.

func MemberArtifact added in v0.8.77

func MemberArtifact() Artifact

func ModeratorArtifact added in v0.8.77

func ModeratorArtifact() Artifact

ModeratorArtifact returns the moderator asset for the running platform. Releases publish the moderator for linux/amd64 only.

func RelayArtifact added in v0.8.77

func RelayArtifact() Artifact

RelayArtifact returns the relay asset for the running platform. Releases publish the relay for linux/amd64 only.

type AssetFetcher added in v0.8.77

type AssetFetcher interface {
	// Read returns a small asset, such as a checksum listing.
	Read(url string) ([]byte, error)
	// Download streams an asset into dstPath and returns its SHA-256.
	Download(url, dstPath string) (checksum string, err error)
}

AssetFetcher retrieves release assets.

type BinaryReplacer added in v0.8.77

type BinaryReplacer interface {
	// Path returns where the running binary lives.
	Path() string
	// StagePath returns a scratch path on the filesystem holding the binary.
	StagePath(name string) string
	// Install puts the binary at path in place of the running one and returns a
	// func rolling back to the previous binary.
	Install(path string) (rollback func(), err error)
	// Restart hands the process over to the installed binary. On success it does
	// not return.
	Restart(shutdownF func()) error
}

BinaryReplacer owns the binary of the running process.

type FailureRegistry added in v0.8.77

type FailureRegistry interface {
	Has(v *semver.Version) bool
	Set(v *semver.Version)
	Clear()
}

FailureRegistry remembers the release that could not replace the binary.

type Release added in v0.8.77

type Release struct {
	Version *semver.Version
	URL     string // page a human downloads it from
	// contains filtered or unexported fields
}

Release is a published release with the assets attached to it.

func (Release) AssetURL added in v0.8.77

func (r Release) AssetURL(name string) (string, error)

AssetURL returns the download URL of the named asset.

type ReleaseSource added in v0.8.77

type ReleaseSource interface {
	Latest() (Release, error)
}

ReleaseSource resolves the newest published release.

type SelfUpdater added in v0.8.77

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

SelfUpdater keeps the running binary in sync with the newest release. A node with an owner to ask - a member node - holds every release until the frontend answers for it; an unattended one installs it right away.

func NewSelfUpdater added in v0.8.77

func NewSelfUpdater(
	ctx context.Context,
	current *semver.Version,
	a Artifact,
	isApprovalRequired bool,
) *SelfUpdater

func (*SelfUpdater) AnswerUpdate added in v0.8.77

func (u *SelfUpdater) AnswerUpdate(isAllowed bool) error

func (*SelfUpdater) Close added in v0.8.77

func (u *SelfUpdater) Close()

func (*SelfUpdater) GetPendingUpdate added in v0.8.77

func (u *SelfUpdater) GetPendingUpdate() (currentVersion, newVersion, releaseURL string)

func (*SelfUpdater) IsInstallable added in v0.8.77

func (u *SelfUpdater) IsInstallable() bool

IsInstallable reports whether this copy can replace its own binary. One that cannot - a build owned by the system package manager - still reports a release, so its owner learns of it and installs it the way it was installed.

func (*SelfUpdater) Run added in v0.8.77

func (u *SelfUpdater) Run(shutdownF func())

Run starts the background update loop. shutdownF releases node resources right before the process is replaced by the new binary; it may be nil.

Jump to

Keyboard shortcuts

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