Documentation
¶
Overview ¶
Package update implements release discovery and secure self-update primitives.
Index ¶
- Constants
- Variables
- func InstallVerified(layout Layout, verified VerifiedUpdate) error
- func IsHomebrew(err error) bool
- func ParseChecksums(data []byte, expected string) ([]byte, error)
- func ValidateArchive(data []byte, expectedExecutable string, maxSize uint64) ([]byte, error)
- type Asset
- type CheckResult
- type CheckState
- type Client
- type HomebrewError
- type Layout
- type LayoutKind
- type Platform
- type Release
- type StateStore
- type VerifiedUpdate
- type Version
Constants ¶
const ( DefaultReleasesURL = "https://api.github.com/repos/Architeg/gloss/releases?per_page=20" DefaultUserAgent = "gloss-updater" )
const HomebrewUpgradeCommand = "brew upgrade Architeg/tap/gloss"
Variables ¶
var ErrUnsupportedPlatform = errors.New("unsupported update platform")
Functions ¶
func InstallVerified ¶
func InstallVerified(layout Layout, verified VerifiedUpdate) error
InstallVerified atomically replaces an eligible manual executable.
func IsHomebrew ¶
IsHomebrew reports whether an error identifies a Homebrew installation.
func ParseChecksums ¶
ParseChecksums returns the expected digest for an exact basename.
Types ¶
type CheckResult ¶
type CheckResult struct {
CurrentVersion string
CurrentValid bool
LatestVersion string
UpdateAvailable bool
PlatformSupported bool
Release Release
}
CheckResult describes a stable release relative to the running version.
type CheckState ¶
type CheckState struct {
LastCompleted time.Time `json:"last_completed"`
LatestVersion string `json:"latest_version,omitempty"`
}
CheckState is the minimal persisted automatic-check state.
type Client ¶
type Client struct {
HTTP *http.Client
ReleasesURL string
UserAgent string
GOOS string
GOARCH string
ReleaseMax int64
ChecksumMax int64
ArchiveMax int64
ExecutableMax uint64
}
Client performs update HTTP operations. Fields are injectable for tests.
func (*Client) DownloadVerified ¶
DownloadVerified downloads checksums and the platform archive, verifies the archive digest, then validates and reads its sole executable.
type HomebrewError ¶
type HomebrewError struct {
Path string
}
HomebrewError explains why self-replacement is forbidden.
func (*HomebrewError) Error ¶
func (e *HomebrewError) Error() string
type Layout ¶
type Layout struct {
Kind LayoutKind
Invoked string
Path string
Mode os.FileMode
Platform Platform
// contains filtered or unexported fields
}
Layout is a validated executable replacement target.
func InspectExecutable ¶
InspectExecutable validates a candidate executable without modifying it.
func InspectRunningExecutable ¶
InspectRunningExecutable validates the current executable's installation layout.
type LayoutKind ¶
type LayoutKind int
LayoutKind classifies how the running executable is managed.
const ( LayoutManual LayoutKind = iota LayoutHomebrew )
type Platform ¶
Platform is the exact release-asset contract for one supported target.
func PlatformFor ¶
PlatformFor returns the exact asset mapping for a supported target.
type StateStore ¶
StateStore persists automatic-check state beside other Gloss-owned data.
func (StateStore) Due ¶
func (s StateStore) Due(interval time.Duration) bool
Due reports whether an automatic check should run. Missing or malformed state is treated as due so it can never prevent application startup.
func (StateStore) Load ¶
func (s StateStore) Load() (CheckState, error)
Load reads state without changing it.
func (StateStore) MarkCompleted ¶
func (s StateStore) MarkCompleted(latest string) (retErr error)
MarkCompleted atomically records a successful release check.
type VerifiedUpdate ¶
VerifiedUpdate contains an archive payload only after checksum and ZIP validation have both succeeded.
type Version ¶
Version is a stable three-component semantic version.
func ParseVersion ¶
ParseVersion accepts an optional leading v and rejects prerelease, build-metadata, and incomplete versions.