Documentation
¶
Overview ¶
Package update orchestrates explicit and automatic updates. It keeps only the coordinator and automatic-check API; implementation lives in the source, release, installer, and process subpackages, re-exported here for the CLI composition root.
Index ¶
- Constants
- Variables
- type AutomaticUpdateChecker
- type AutomaticUpdateCheckerOptions
- type AutomaticUpdateNotice
- type AutomaticUpdateRequest
- type Command
- type CommandRunner
- type GitHubReleaseClient
- type InstallSource
- type Release
- type ReleaseAsset
- type ReleaseBinaryChecker
- type ReleaseCache
- type ReleaseCheckOptions
- type ReleaseCheckResult
- type ReleaseChecker
- type ReleaseClientOptions
- type ReleaseFileReplacer
- type ReleaseInstaller
- type ReleaseInstallerOptions
- type SourceDetector
- type SourceDetectorFunc
- type UpdateCoordinator
- type UpdateCoordinatorOptions
- type UpdateRequest
- type UpdateResult
Constants ¶
const ( InstallSourceDevelopment = installer.InstallSourceDevelopment InstallSourceHomebrewStable = installer.InstallSourceHomebrewStable InstallSourceHomebrewBeta = installer.InstallSourceHomebrewBeta InstallSourceGoInstall = installer.InstallSourceGoInstall InstallSourceRelease = installer.InstallSourceRelease )
Variables ¶
var ( DetectInstallSource = installer.DetectInstallSource NewReleaseInstaller = installer.NewReleaseInstaller NewCommandRunner = process.NewCommandRunner CleanupPendingWindowsUpdate = installer.CleanupPendingWindowsUpdate ReleaseSigningKeyID = installer.ReleaseSigningKeyID )
这些构造器/函数是 composition root 需要的别名;默认 release cache 由本根组装。
var ReleaseSigningPublicKey = installer.ReleaseSigningPublicKey
ReleaseSigningPublicKey 是生产 Release 签名使用的受信 Ed25519 公钥。
Functions ¶
This section is empty.
Types ¶
type AutomaticUpdateChecker ¶
type AutomaticUpdateChecker struct {
// contains filtered or unexported fields
}
AutomaticUpdateChecker 在普通 CLI 命令成功后判断是否应提示稳定版更新。
func NewAutomaticUpdateChecker ¶
func NewAutomaticUpdateChecker(options AutomaticUpdateCheckerOptions) (*AutomaticUpdateChecker, error)
NewAutomaticUpdateChecker 建立自动更新检查器。
func (*AutomaticUpdateChecker) Check ¶
func (c *AutomaticUpdateChecker) Check(ctx context.Context, request AutomaticUpdateRequest) (*AutomaticUpdateNotice, error)
Check 查询稳定版更新,并仅在较新版本存在时返回提示。 开发构建没有发布渠道,必须在读取本机安装来源或访问网络前返回。
type AutomaticUpdateCheckerOptions ¶
type AutomaticUpdateCheckerOptions struct {
SourceDetector SourceDetector
ReleaseChecker ReleaseChecker
}
AutomaticUpdateCheckerOptions 注入自动检查所需的只读依赖。 自动检查不执行安装命令,也不接触 Release 资产。
type AutomaticUpdateNotice ¶
type AutomaticUpdateNotice struct {
Source InstallSource
CurrentVersion string
LatestVersion string
UpdateCommand string
}
AutomaticUpdateNotice 是 CLI 可安全展示的更新提示。 UpdateCommand 是安装来源对应的准确后续命令,不会在检查阶段执行。
type AutomaticUpdateRequest ¶
AutomaticUpdateRequest 描述当前二进制的构建信息。
type CommandRunner ¶
type CommandRunner = process.CommandRunner
re-exports from the process package: the no-shell command runner.
type GitHubReleaseClient ¶
type GitHubReleaseClient = release.GitHubReleaseClient
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
func NewGitHubReleaseClient ¶
func NewGitHubReleaseClient(options ReleaseClientOptions) (*GitHubReleaseClient, error)
NewGitHubReleaseClient 建立 GitHub Releases 查询客户端。未显式注入 Cache 时, 使用安装器提供的文件 cache 并落在应用数据目录。
type InstallSource ¶
type InstallSource = installer.InstallSource
re-exports from the installer package: install-source detection and the release installer.
type Release ¶
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseAsset ¶
type ReleaseAsset = release.ReleaseAsset
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseBinaryChecker ¶
type ReleaseBinaryChecker = installer.ReleaseBinaryChecker
re-exports from the installer package: install-source detection and the release installer.
type ReleaseCache ¶ added in v1.0.0
type ReleaseCache = release.ReleaseCache
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseCheckOptions ¶
type ReleaseCheckOptions = release.ReleaseCheckOptions
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseCheckResult ¶
type ReleaseCheckResult = release.ReleaseCheckResult
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseChecker ¶
type ReleaseChecker = release.ReleaseChecker
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseClientOptions ¶
type ReleaseClientOptions = release.ReleaseClientOptions
re-exports from the release package: release values, channel policy, the release cache port, and the GitHub release client.
type ReleaseFileReplacer ¶
type ReleaseFileReplacer = installer.ReleaseFileReplacer
re-exports from the installer package: install-source detection and the release installer.
type ReleaseInstaller ¶
type ReleaseInstaller = installer.ReleaseInstaller
re-exports from the installer package: install-source detection and the release installer.
type ReleaseInstallerOptions ¶
type ReleaseInstallerOptions = installer.ReleaseInstallerOptions
re-exports from the installer package: install-source detection and the release installer.
type SourceDetector ¶
type SourceDetector = installer.SourceDetector
re-exports from the installer package: install-source detection and the release installer.
type SourceDetectorFunc ¶
type SourceDetectorFunc = installer.SourceDetectorFunc
re-exports from the installer package: install-source detection and the release installer.
type UpdateCoordinator ¶
type UpdateCoordinator struct {
// contains filtered or unexported fields
}
UpdateCoordinator 按安装渠道编排显式更新,不负责下载资产细节。
func NewUpdateCoordinator ¶
func NewUpdateCoordinator(options UpdateCoordinatorOptions) (*UpdateCoordinator, error)
NewUpdateCoordinator 建立可测试的更新策略编排器。
func (*UpdateCoordinator) Execute ¶
func (c *UpdateCoordinator) Execute(ctx context.Context, request UpdateRequest) (UpdateResult, error)
Execute 查询更新并在非 check 模式下执行来源对应的更新策略。
type UpdateCoordinatorOptions ¶
type UpdateCoordinatorOptions struct {
SourceDetector SourceDetector
ReleaseChecker ReleaseChecker
CommandRunner CommandRunner
ReleaseInstaller ReleaseInstaller
}
UpdateCoordinatorOptions 注入更新策略需要的外部依赖,供 CLI 和受控测试复用。
type UpdateRequest ¶
UpdateRequest 描述一次显式 update 命令的用户选择。
type UpdateResult ¶
type UpdateResult struct {
Source InstallSource `json:"source"`
CurrentVersion string `json:"current_version"`
LatestVersion *string `json:"latest_version"`
LatestPrerelease bool `json:"latest_prerelease"`
UpdateAvailable bool `json:"update_available"`
}
UpdateResult 是检查或执行更新后可安全展示的状态。
Directories
¶
| Path | Synopsis |
|---|---|
|
Package installer installs a verified release binary and owns the trust root, install-source detection, cache file permissions, and pending-update cleanup.
|
Package installer installs a verified release binary and owns the trust root, install-source detection, cache file permissions, and pending-update cleanup. |
|
Package process runs update commands as child processes.
|
Package process runs update commands as child processes. |
|
Package release queries GitHub Releases and applies the SemVer channel policy.
|
Package release queries GitHub Releases and applies the SemVer channel policy. |
|
Package source resolves and selects the built-in GitHub Releases transport paths.
|
Package source resolves and selects the built-in GitHub Releases transport paths. |