update

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const ManagedEnvName = "AGH_MANAGED"

ManagedEnvName overrides the install-method detector for managed package installs.

Variables

View Source
var ErrNoCachedRelease = errors.New("update: cached release info not found")

Functions

This section is empty.

Types

type AppliedBinary

type AppliedBinary struct {
	TargetPath string
	BackupPath string
	Version    string
}

AppliedBinary describes one on-disk binary swap that still retains a rollback backup.

type BinaryApplier

type BinaryApplier interface {
	ApplyBinary(sourcePath string, targetPath string, backupPath string, mode os.FileMode) error
	RestoreBinary(backupPath string, targetPath string, mode os.FileMode) error
}

BinaryApplier atomically swaps the current executable with a verified replacement.

type BundleVerifier

type BundleVerifier interface {
	VerifyChecksums(ctx context.Context, checksumsPath string, bundlePath string) error
}

BundleVerifier verifies the signed checksum catalog before the archive checksum is trusted.

type CheckOptions

type CheckOptions struct {
	ForceRefresh         bool
	AllowCachedOnFailure bool
}

CheckOptions customize one update status query.

type Config

type Config struct {
	HomePaths       aghconfig.HomePaths
	CurrentVersion  string
	ExecutablePath  func() (string, error)
	ResolveSymlinks func(string) (string, error)
	Getenv          func(string) string
	Now             func() time.Time
	HTTPClient      *http.Client
	RuntimeOS       string
	RuntimeArch     string
	LookPath        func(string) (string, error)
	RunCommand      func(context.Context, string, ...string) (string, error)
	BundleVerifier  BundleVerifier
	BinaryApplier   BinaryApplier
}

Config builds one update manager bound to the current runtime.

type InstallMethod

type InstallMethod string

InstallMethod reports how the running AGH binary was installed.

const (
	InstallMethodDirectBinary InstallMethod = "direct-binary"
	InstallMethodHomebrew     InstallMethod = "homebrew"
	InstallMethodNPM          InstallMethod = "npm"
	InstallMethodAPT          InstallMethod = "apt"
	InstallMethodDNF          InstallMethod = "dnf"
	InstallMethodRPM          InstallMethod = "rpm"
	InstallMethodScoop        InstallMethod = "scoop"
	InstallMethodGoInstall    InstallMethod = "go-install"
	InstallMethodUnknown      InstallMethod = "unknown"
)

type Manager

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

Manager owns the AGH self-update flow for the current runtime.

func NewManager

func NewManager(cfg Config) (*Manager, error)

NewManager binds the update flow to the current AGH runtime.

func (*Manager) ApplyRelease

func (m *Manager) ApplyRelease(ctx context.Context, release *Release) (AppliedBinary, error)

ApplyRelease downloads, verifies, extracts, and swaps in the supplied release.

func (*Manager) Check

func (m *Manager) Check(ctx context.Context, opts CheckOptions) (State, *Release, error)

Check returns the current update state and the latest release metadata when available.

func (*Manager) Finalize

func (m *Manager) Finalize(applied AppliedBinary) error

Finalize removes the preserved sibling backup after the full update flow succeeds.

func (*Manager) PrimeInstallDetection

func (m *Manager) PrimeInstallDetection(ctx context.Context)

PrimeInstallDetection resolves and memoizes the install method for this manager.

func (*Manager) Restore

func (m *Manager) Restore(applied AppliedBinary) error

Restore rolls back an applied binary swap using the preserved sibling backup.

type Release

type Release struct {
	Version     string
	ReleaseURL  string
	PublishedAt time.Time
	Assets      []ReleaseAsset
}

Release holds the metadata required to inspect or apply one release.

type ReleaseAsset

type ReleaseAsset struct {
	Name        string
	DownloadURL string
}

ReleaseAsset identifies one downloadable release artifact.

type State

type State struct {
	Supported      bool       `json:"supported"`
	Managed        bool       `json:"managed"`
	InstallMethod  string     `json:"install_method"`
	CurrentVersion string     `json:"current_version"`
	LatestVersion  string     `json:"latest_version,omitempty"`
	Available      bool       `json:"available"`
	Status         Status     `json:"status"`
	Recommendation string     `json:"recommendation,omitempty"`
	ReleaseURL     string     `json:"release_url,omitempty"`
	CheckedAt      *time.Time `json:"checked_at,omitempty"`
	LastError      string     `json:"last_error,omitempty"`
	Message        string     `json:"message,omitempty"`
}

State is the transport-safe update status snapshot shared by CLI and API surfaces.

type Status

type Status string

Status reports the operator-facing update state.

const (
	StatusCurrent     Status = "current"
	StatusAvailable   Status = "available"
	StatusUpdated     Status = "updated"
	StatusDeferred    Status = "deferred"
	StatusUnsupported Status = "unsupported"
	StatusFailed      Status = "failed"
)

Jump to

Keyboard shortcuts

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