Documentation
¶
Index ¶
- Constants
- Variables
- type AppliedBinary
- type BinaryApplier
- type BundleVerifier
- type CheckOptions
- type Config
- type InstallMethod
- type Manager
- func (m *Manager) ApplyRelease(ctx context.Context, release *Release) (AppliedBinary, error)
- func (m *Manager) Check(ctx context.Context, opts CheckOptions) (State, *Release, error)
- func (m *Manager) Finalize(applied AppliedBinary) error
- func (m *Manager) PrimeInstallDetection(ctx context.Context)
- func (m *Manager) Restore(applied AppliedBinary) error
- type Release
- type ReleaseAsset
- type State
- type Status
Constants ¶
const ManagedEnvName = "AGH_MANAGED"
ManagedEnvName overrides the install-method detector for managed package installs.
Variables ¶
var ErrNoCachedRelease = errors.New("update: cached release info not found")
Functions ¶
This section is empty.
Types ¶
type AppliedBinary ¶
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 ¶
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 ¶
NewManager binds the update flow to the current AGH runtime.
func (*Manager) ApplyRelease ¶
ApplyRelease downloads, verifies, extracts, and swaps in the supplied release.
func (*Manager) Check ¶
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 ¶
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 ¶
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.